Esempio n. 1
0
 /**
  * Send response
  *
  * @param DispatcherResponseInterface $response
  * @return boolean  Returns true if the response has been send, otherwise FALSE
  */
 public function send(DispatcherResponseInterface $response)
 {
     //Cleanup and flush output to client
     if (!function_exists('fastcgi_finish_request')) {
         if (PHP_SAPI !== 'cli') {
             for ($i = 0; $i < ob_get_level(); $i++) {
                 ob_end_flush();
             }
             flush();
         }
     } else {
         fastcgi_finish_request();
     }
     //Set the exit status based on the status code.
     $status = 0;
     if (!$response->isSuccess()) {
         $status = (int) $response->getStatusCode();
     }
     exit($status);
     return true;
 }
Esempio n. 2
0
 /**
  * Sends content for the current web response.
  *
  * We flush the data to the output buffer based on the chunk size and range information provided in the request.
  * The default chunk size is 8 MB.
  *
  * @param DispatcherResponseInterface $response
  * @return DispatcherResponseTransportRedirect
  */
 public function sendContent(DispatcherResponseInterface $response)
 {
     if ($response->isSuccess()) {
         //For a certain unmentionable browser
         if (ini_get('zlib.output_compression')) {
             @ini_set('zlib.output_compression', 'Off');
         }
         //Fix for IE7/8
         if (function_exists('apache_setenv')) {
             apache_setenv('no-gzip', '1');
         }
         //Remove PHP time limit
         if (!ini_get('safe_mode')) {
             @set_time_limit(0);
         }
         $stream = $response->getStream();
         $offset = $this->getOffset($response);
         $range = $this->getRange($response);
         $chunk = $this->getChunkSize();
         if ($offset > 0) {
             $stream->seek($offset);
         }
         $stream->flush($chunk, $range);
         $stream->close();
         return $this;
     }
     parent::sendContent($response);
 }
Esempio n. 3
0
 /**
  * Sends content for the current web response.
  *
  * We flush(stream) the data to the output buffer based on the chunk size and range information provided in the
  * request. The default chunk size is 8 MB.
  *
  * @param DispatcherResponseInterface $response
  * @return DispatcherResponseTransportRedirect
  */
 public function sendContent(DispatcherResponseInterface $response)
 {
     if ($response->isSuccess()) {
         //For a certain unmentionable browser
         if (ini_get('zlib.output_compression')) {
             @ini_set('zlib.output_compression', 'Off');
         }
         //Fix for IE7/8
         if (function_exists('apache_setenv')) {
             @apache_setenv('no-gzip', '1');
         }
         //Remove PHP time limit
         if (!ini_get('safe_mode')) {
             @set_time_limit(0);
         }
         if ($response->isStreamable() && $response->getRequest()->isStreaming()) {
             //Make sure the output buffers are cleared
             $level = ob_get_level();
             while ($level > 0) {
                 ob_end_clean();
                 $level--;
             }
             $stream = $response->getStream();
             $offset = $this->getOffset($response);
             $range = $this->getRange($response);
             if ($offset > 0) {
                 $stream->seek($offset);
             }
             $output = fopen('php://output', 'w+');
             $stream->flush($output, $range);
             $stream->close();
             fclose($output);
             return $this;
         } else {
             return parent::sendContent($response);
         }
     }
     return parent::sendContent($response);
 }