Cake\Http\ResponseEmitter::emit PHP Метод

emit() публичный Метод

{@inheritDoc}
public emit ( Psr\Http\Message\ResponseInterface $response, $maxBufferLength = 8192 )
$response Psr\Http\Message\ResponseInterface
    public function emit(ResponseInterface $response, $maxBufferLength = 8192)
    {
        $file = $line = null;
        if (headers_sent($file, $line)) {
            $message = "Unable to emit headers. Headers sent in file={$file} line={$line}";
            if (Configure::read('debug')) {
                trigger_error($message, E_USER_WARNING);
            } else {
                Log::warning($message);
            }
        }
        $this->emitStatusLine($response);
        $this->emitHeaders($response);
        $this->flush();
        $range = $this->parseContentRange($response->getHeaderLine('Content-Range'));
        if (is_array($range)) {
            $this->emitBodyRange($range, $response, $maxBufferLength);
        } else {
            $this->emitBody($response, $maxBufferLength);
        }
        if (function_exists('fastcgi_finish_request')) {
            fastcgi_finish_request();
        }
    }

Usage Example

Пример #1
0
 /**
  * Emit the response using the PHP SAPI.
  *
  * @param \Psr\Http\Message\ResponseInterface $response The response to emit
  * @param \Zend\Diactoros\Response\EmitterInterface|null $emitter The emitter to use.
  *   When null, a SAPI Stream Emitter will be used.
  * @return void
  */
 public function emit(ResponseInterface $response, EmitterInterface $emitter = null)
 {
     $stream = $response->getBody();
     if (!$emitter) {
         $emitter = new ResponseEmitter();
     }
     $emitter->emit($response);
 }