Documentation

SapiEmitter extends ResponseEmitterAbstract
in package

Table of Contents

Properties

$body  : StreamInterface
$bufferSize  : int
$hasContentRange  : bool
$hasCustomLength  : bool
$rangeLength  : int
$rangeStart  : int
$response  : ResponseInterface

Methods

__construct()  : mixed
ResponseEmitter constructor
emit()  : void
Emits a PSR-7 response.
emitBody()  : void
emits the body of the given response with respect to the parameters given in content-range and content-length headers
emitBodyRange()  : void
emits a part of the body
emitBuffer()  : void
emits the given buffer
emitHeaders()  : void
Emits the headers
getStatusLine()  : string
Returns a full status line for the given response, e.g. "HTTP/1.1 200 OK"
hasBody()  : bool
Checks whether the response has (or is supposed to have) a body
parseContentRange()  : array{0: int, 1: int, 2: int|null, 3: int}|null
sendHeader()  : void
Allow to intercept header calls in tests
setContentLengthHeader()  : void
Sets/adjusts the Content-Length header

Properties

Methods

__construct()

ResponseEmitter constructor

public __construct(ResponseInterface $response[, int $bufferSize = 65536 ]) : mixed
Parameters
$response : ResponseInterface
$bufferSize : int = 65536

emitBody()

emits the body of the given response with respect to the parameters given in content-range and content-length headers

protected emitBody() : void

emitBodyRange()

emits a part of the body

protected emitBodyRange(int $start, int $length) : void
Parameters
$start : int
$length : int

emitBuffer()

emits the given buffer

protected emitBuffer(string $buffer) : void
Parameters
$buffer : string
Tags
codeCoverageIgnore

(overridden in test)

emitHeaders()

Emits the headers

protected emitHeaders() : void

There are two special-case header calls. The first is a header that starts with the string "HTTP/" (case is not significant), which will be used to figure out the HTTP status code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the ErrorDocument directive), you may want to make sure that your script generates the proper status code.

The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set.

Tags
see
https://www.php.net/manual/en/function.header.php

getStatusLine()

Returns a full status line for the given response, e.g. "HTTP/1.1 200 OK"

protected getStatusLine() : string
Return values
string

sendHeader()

Allow to intercept header calls in tests

protected sendHeader(string $header, bool $replace[, int $response_code = 0 ]) : void
Parameters
$header : string
$replace : bool
$response_code : int = 0
Tags
codeCoverageIgnore

(overridden in test)


        
On this page

Search results