PHP Интерфейс Aerys\Response

Показать файл Открыть проект Примеры использования интерфейса

Открытые методы

Метод Описание
addHeader ( string $field, string $value ) : aerys\Response Append the specified header
end ( string $finalBodyChunk = null ) Signify the end of streaming response output
flush ( ) Request that buffered stream data be flushed to the client
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)
setCookie ( string $name, string $value, array $flags = [] ) : aerys\Response Provides an easy API to set cookie headers Those who prefer using addHeader() may do so.
setHeader ( string $field, string $value ) : aerys\Response Set the specified header
setReason ( string $phrase ) : aerys\Response Set the optional HTTP reason phrase
setStatus ( integer $code ) : aerys\Response Set the numeric HTTP status code
state ( ) : integer Retrieve the current response state
stream ( string $partialBodyChunk ) : Amp\Promise Incrementally stream parts of the response entity body

Описание методов

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

Append the specified header
public addHeader ( string $field, string $value ) : aerys\Response
$field string
$value string
Результат aerys\Response

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

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).
public end ( string $finalBodyChunk = null )
$finalBodyChunk string Optional final body data to send

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

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

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

Indicate resources which a client likely needs to fetch. (e.g. Link: preload or HTTP/2 Server Push)
public push ( string $url, array $headers = null ) : aerys\Response
$url string The URL this request should be dispatched to
$headers array Optional custom headers, else the server will try to reuse headers from the last request
Результат aerys\Response

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

Provides an easy API to set cookie headers Those who prefer using addHeader() may do so.
public setCookie ( string $name, string $value, array $flags = [] ) : aerys\Response
$name string
$value string
$flags array Shall be an array of key => value pairs and/or unkeyed values as per https://tools.ietf.org/html/rfc6265#section-5.2.1
Результат aerys\Response

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

This method will replace any existing headers for the specified field.
public setHeader ( string $field, string $value ) : aerys\Response
$field string
$value string
Результат aerys\Response

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

Set the optional HTTP reason phrase
public setReason ( string $phrase ) : aerys\Response
$phrase string A human readable string describing the status code
Результат aerys\Response

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

If not assigned this value defaults to 200.
public setStatus ( integer $code ) : aerys\Response
$code integer An integer in the range [100-599]
Результат aerys\Response

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

The response state is a bitmask of the following flags: - Response::NONE - Response::STARTED - Response::STREAMING - Response::ENDED
public state ( ) : integer
Результат integer

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

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().
public stream ( string $partialBodyChunk ) : Amp\Promise
$partialBodyChunk string A portion of the response entity body
Результат Amp\Promise to be succeeded whenever local buffers aren't full