PHP Class Cake\Http\ResponseEmitter

This emitter offers a few changes from the emitters offered by diactoros: - It logs headers sent using CakePHP's logging tools. - Cookies are emitted using setcookie() to not conflict with ext/session
Inheritance: implements Zend\Diactoros\Response\EmitterInterface
Show file Open project: cakephp/cakephp Class Usage Examples

Public Methods

Method Description
emit ( Psr\Http\Message\ResponseInterface $response, $maxBufferLength = 8192 ) {@inheritDoc}

Protected Methods

Method Description
emitBody ( Psr\Http\Message\ResponseInterface $response, integer $maxBufferLength ) : void Emit the message body.
emitBodyRange ( array $range, Psr\Http\Message\ResponseInterface $response, integer $maxBufferLength ) : void Emit a range of the message body.
emitCookies ( array $cookies ) : void Emit cookies using setcookie()
emitHeaders ( Psr\Http\Message\ResponseInterface $response ) : void Emit response headers.
emitStatusLine ( Psr\Http\Message\ResponseInterface $response ) : void Emit the status line.
flush ( integer | null $maxBufferLevel = null ) : void Loops through the output buffer, flushing each, before emitting the response.
parseContentRange ( string $header ) : false | array Parse content-range header http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16

Method Details

emit() public method

{@inheritDoc}
public emit ( Psr\Http\Message\ResponseInterface $response, $maxBufferLength = 8192 )
$response Psr\Http\Message\ResponseInterface

emitBody() protected method

Emit the message body.
protected emitBody ( Psr\Http\Message\ResponseInterface $response, integer $maxBufferLength ) : void
$response Psr\Http\Message\ResponseInterface The response to emit
$maxBufferLength integer The chunk size to emit
return void

emitBodyRange() protected method

Emit a range of the message body.
protected emitBodyRange ( array $range, Psr\Http\Message\ResponseInterface $response, integer $maxBufferLength ) : void
$range array The range data to emit
$response Psr\Http\Message\ResponseInterface The response to emit
$maxBufferLength integer The chunk size to emit
return void

emitCookies() protected method

Emit cookies using setcookie()
protected emitCookies ( array $cookies ) : void
$cookies array An array of Set-Cookie headers.
return void

emitHeaders() protected method

Loops through each header, emitting each; if the header value is an array with multiple values, ensures that each is sent in such a way as to create aggregate headers (instead of replace the previous).
protected emitHeaders ( Psr\Http\Message\ResponseInterface $response ) : void
$response Psr\Http\Message\ResponseInterface The response to emit
return void

emitStatusLine() protected method

Emits the status line using the protocol version and status code from the response; if a reason phrase is availble, it, too, is emitted.
protected emitStatusLine ( Psr\Http\Message\ResponseInterface $response ) : void
$response Psr\Http\Message\ResponseInterface The response to emit
return void

flush() protected method

Loops through the output buffer, flushing each, before emitting the response.
protected flush ( integer | null $maxBufferLevel = null ) : void
$maxBufferLevel integer | null Flush up to this buffer level.
return void

parseContentRange() protected method

Parse content-range header http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16
protected parseContentRange ( string $header ) : false | array
$header string The Content-Range header to parse.
return false | array [unit, first, last, length]; returns false if no content range or an invalid content range is provided