IPB

Willkommen, Gast ( Anmelden | Registrierung )

 
Reply to this topicStart new topic
> [PHP] Chunked buffered content processing
Wertung 4 V
jan
Beitrag Apr 24 2009, 13:42 PM
Beitrag #1


Administrator
***

Gruppe: Admin
Beiträge: 552
Mitglied seit: 1-June 05
Wohnort: germany, hassia, bickenbach
Mitglieds-Nr.: 1



Loads static content chunk-wise while sending it.

CODE
  /**
   * Chunk buffered content processing
   *
   * Loads static content chunk-wise while sending it.
   */
  protected function streamContents($file)
  {
    $chunksize = 1024*32; // 32kB buffer size
    $buffer = '';
    $handle = fopen($file, 'rb');
    $cnt = 0;

    ob_start();
    while (!feof($handle))
    {
        $buffer = fread($handle, $chunksize);
        echo $buffer;
        ob_flush();
        flush();
        $cnt += strlen($buffer);
    }
    ob_end_flush();

    if(fclose($handle))
      Logger::instance()->info("Sent file $file ($cnt bytes)");
  }


--------------------
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 Besucher lesen dieses Thema (Gäste: 1 | Anonyme Besucher: 0)
0 Mitglieder:

Collapse

> Similar Topics

  Thema Replies Topic Starter Views Last Action
No New Posts Content Delivery for Mobile Devices
Best Practise
0 jan 66,969 26th August 2008 - 11:31 AM
Last post by: jan
No New Posts PHP-JSON
Ressourcen
0 jan 40,871 27th September 2007 - 08:59 AM
Last post by: jan
No New Posts phpsessid abschalten
damit sie in Google nicht mehr auftaucht
0 jan 48,199 20th January 2007 - 14:01 PM
Last post by: jan


 

- Vereinfachte Darstellung Aktuelles Datum: 15th June 2021 - 04:01 AM