PHP 인터페이스 Aerys\Response

파일 보기 프로젝트 열기: amphp/aerys 0 사용 예제들

공개 메소드들

메소드 설명
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