Class ResponseEmitter
Emits a Response to the PHP Server API.
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
- Cake\Http\ResponseEmitter implements Zend\Diactoros\Response\EmitterInterface
Method Summary
- emit() public
- emitBody() protectedEmit the message body.
- emitBodyRange() protectedEmit a range of the message body.
- emitCookies() protectedEmit cookies using setcookie()
- emitHeaders() protectedEmit response headers.
- emitStatusLine() protectedEmit the status line.
- flush() protected
Loops through the output buffer, flushing each, before emitting the response.
- parseContentRange() protected
Parse content-range header https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16
Method Detail
emit()source public
emit( Psr\Http\Message\ResponseInterface $response , $maxBufferLength 8192 )
emitBody()source protected
emitBody( Psr\Http\Message\ResponseInterface $response , integer $maxBufferLength )
Emit the message body.
Parameters
- Psr\Http\Message\ResponseInterface
$response
- The response to emit
- integer
$maxBufferLength
- The chunk size to emit
emitBodyRange()source protected
emitBodyRange( array $range , Psr\Http\Message\ResponseInterface $response , integer $maxBufferLength )
Emit a range of the message body.
Parameters
- array
$range
- The range data to emit
- Psr\Http\Message\ResponseInterface
$response
- The response to emit
- integer
$maxBufferLength
- The chunk size to emit
emitCookies()source protected
emitCookies( array $cookies )
Emit cookies using setcookie()
Parameters
- array
$cookies
- An array of Set-Cookie headers.
emitHeaders()source protected
emitHeaders( Psr\Http\Message\ResponseInterface $response )
Emit response headers.
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).
Parameters
- Psr\Http\Message\ResponseInterface
$response
- The response to emit
emitStatusLine()source protected
emitStatusLine( Psr\Http\Message\ResponseInterface $response )
Emit the status line.
Emits the status line using the protocol version and status code from the response; if a reason phrase is available, it, too, is emitted.
Parameters
- Psr\Http\Message\ResponseInterface
$response
- The response to emit
flush()source protected
flush( integer|null $maxBufferLevel null )
Loops through the output buffer, flushing each, before emitting the response.
Parameters
- integer|null
$maxBufferLevel
optional null - Flush up to this buffer level.
parseContentRange()source protected
parseContentRange( string $header )
Parse content-range header https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16
Parameters
- string
$header
- The Content-Range header to parse.
Returns
false|array[unit, first, last, length]; returns false if no content range or an invalid content range is provided
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.Http.ResponseEmitter.html