Aerys\Response interface Response

Summary

Properties

Methods

Methods

setStatus — public function setStatus(int $code): self

Set the numeric HTTP status code

If not assigned this value defaults to 200.

Type Parameter Description Default Value
int $code An integer in the range [100-599] none
setReason — public function setReason(string $phrase): self

Set the optional HTTP reason phrase

Type Parameter Description Default Value
string $phrase A human readable string describing the status code none
addHeader — public function addHeader(string $field, string $value): self

Append the specified header

Type Parameter Description Default Value
string $field No documentation. none
string $value No documentation. none
setHeader — public function setHeader(string $field, string $value): self

Set the specified header

This method will replace any existing headers for the specified field.

Type Parameter Description Default Value
string $field No documentation. none
string $value No documentation. none
setCookie — public function setCookie(string $name, string $value, array $flags = []): self

Provides an easy API to set cookie headers Those who prefer using addHeader() may do so.

Type Parameter Description Default Value
string $name No documentation. none
string $value No documentation. none
array $flags Shall be an array of key => value pairs and/or unkeyed values as per https://tools.ietf.org/html/rfc6265#section-5.2.1 []
stream — public function stream(string $partialBodyChunk): Amp\Promise

Incrementally stream parts of the response entity body

This method may be repeatedly called to stream the response body. Applications that can afford to buffer an entire response in memory or can wait for all body data to generate may use Response::end() to output the entire response in a single call.

Note: Headers are sent upon the first invocation of Response::stream().

Type Parameter Description Default Value
string $partialBodyChunk A portion of the response entity body none
flush — public function flush()

Request that buffered stream data be flushed to the client

This method only makes sense when streaming output via Response::stream(). Invoking it before calling stream() or after end() is a logic error.

end — public function end(string $finalBodyChunk = null)

Signify the end of streaming response output

User applications are NOT required to call Response::end() after streaming or sending response data (though it's not incorrect to do so) -- the server will automatically call end() as needed.

Passing the optional $finalBodyChunk parameter is a shortcut equivalent to the following:

$response->stream($finalBodyChunk);
$response->end();

Note: Invoking Response::end() with a non-empty $finalBodyChunk parameter without having previously invoked Response::stream() is equivalent to calling Response::send($finalBodyChunk).

Type Parameter Description Default Value
string $finalBodyChunk Optional final body data to send null
push — public function push(string $url, array $headers = null): Aerys\Response

Indicate resources which a client likely needs to fetch. (e.g. Link: preload or HTTP/2 Server Push)

Type Parameter Description Default Value
string $url The URL this request should be dispatched to none
array $headers Optional custom headers, else the server will try to reuse headers from the last request null
state — public function state(): int

Retrieve the current response state

The response state is a bitmask of the following flags: