PHP Класс AppserverIo\Appserver\ServletEngine\Http\Response

Автор: Tim Wagner ([email protected])
Наследование: implements AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
addCookie ( AppserverIo\Psr\HttpMessage\CookieInterface $cookie ) : void Adds a cookie.
addHeader ( string $name, string $value, boolean $append = false ) : void Adds a header information got from connection. We've to take care that headers like Set-Cookie header can exist multiple times. To support this create an array that keeps the multiple header values.
appendBodyStream ( string $content ) : void Appends the content.
copyBodyStream ( resource $sourceStream, integer $maxlength = null, integer $offset ) : integer Copies a source stream to body stream.
getBodyContent ( ) : string Return content
getBodyStream ( ) : resource Returns the body stream as a resource.
getCookie ( string $cookieName ) : mixed Returns the cookie with the a cookie
getCookies ( ) : array Returns the cookies.
getException ( ) : Exception | null Returns the exception bound to the response.
getHeader ( string $name ) : mixed Returns header by given name.
getHeaders ( ) : array Returns all headers as array
getHeadersAsString ( ) : string Returns the headers as string
getState ( ) : integer Returns the current state
getStatusCode ( ) : integer Returns the response status code
getStatusReasonPhrase ( ) : string Returns the status phrase based on the status code
getVersion ( ) : string Returns the http version of the response
hasCookie ( string $cookieName ) : boolean Returns TRUE if the response already has a cookie with the passed name, else FALSE.
hasException ( ) : boolean Queries whether the response contains an exception or not.
hasHeader ( string $name ) : boolean Check's if header exists by given name
hasState ( integer $state ) : boolean Compares current state with given state
init ( ) : void Initialises the response object to default properties.
redirect ( string $url, integer $code = 301 ) : void Redirects to the passed URL by adding a 'Location' header and setting the appropriate status code, by default 301.
removeHeader ( string $name ) : void Removes the header with the passed name.
resetBodyStream ( ) : void Reset the body stream
setBodyStream ( resource $bodyStream ) : void Resetss the stream resource pointing to body content.
setException ( Exception $exception ) : void Binds the exception to the response.
setHeaders ( array $headers ) : void Resets all headers by given array
setState ( integer $state ) : void Sets state of response
setStatusCode ( integer $code ) : void Sets the http response status code
setStatusReasonPhrase ( string $statusReasonPhrase ) : void Sets the status reason phrase

Защищенные методы

Метод Описание
initDefaultHeaders ( ) : void Initializes the response with the default headers.

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

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

Adds a cookie.
public addCookie ( AppserverIo\Psr\HttpMessage\CookieInterface $cookie ) : void
$cookie AppserverIo\Psr\HttpMessage\CookieInterface The cookie instance to add
Результат void

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

Adds a header information got from connection. We've to take care that headers like Set-Cookie header can exist multiple times. To support this create an array that keeps the multiple header values.
public addHeader ( string $name, string $value, boolean $append = false ) : void
$name string The header name
$value string The headers value
$append boolean If TRUE and a header with the passed name already exists, the value will be appended
Результат void

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

Appends the content.
public appendBodyStream ( string $content ) : void
$content string The content to append
Результат void

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

Copies a source stream to body stream.
public copyBodyStream ( resource $sourceStream, integer $maxlength = null, integer $offset ) : integer
$sourceStream resource The file pointer to source stream
$maxlength integer The max length to read from source stream
$offset integer The offset from source stream to read
Результат integer The total number of bytes copied

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

Return content
public getBodyContent ( ) : string
Результат string $content

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

Returns the body stream as a resource.
public getBodyStream ( ) : resource
Результат resource The body stream

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

Returns the cookie with the a cookie
public getCookie ( string $cookieName ) : mixed
$cookieName string Name of the cookie to be checked
Результат mixed The cookie instance or an array of cookie instances

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

Returns the cookies.
public getCookies ( ) : array
Результат array The cookies

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

Returns the exception bound to the response.
public getException ( ) : Exception | null
Результат Exception | null The exception

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

Returns header by given name.
public getHeader ( string $name ) : mixed
$name string The header name to get
Результат mixed Usually a string, but can also be an array if we request the Set-Cookie header

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

Returns all headers as array
public getHeaders ( ) : array
Результат array

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

Returns the headers as string
public getHeadersAsString ( ) : string
Результат string

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

Returns the current state
public getState ( ) : integer
Результат integer

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

Returns the response status code
public getStatusCode ( ) : integer
Результат integer

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

Returns the status phrase based on the status code
public getStatusReasonPhrase ( ) : string
Результат string

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

Returns the http version of the response
public getVersion ( ) : string
Результат string

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

Returns TRUE if the response already has a cookie with the passed name, else FALSE.
public hasCookie ( string $cookieName ) : boolean
$cookieName string Name of the cookie to be checked
Результат boolean TRUE if the response already has the cookie, else FALSE

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

Queries whether the response contains an exception or not.
public hasException ( ) : boolean
Результат boolean TRUE if an exception has been attached, else FALSE

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

Check's if header exists by given name
public hasHeader ( string $name ) : boolean
$name string The header name to check
Результат boolean

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

Compares current state with given state
public hasState ( integer $state ) : boolean
$state integer The state to compare with
Результат boolean Whether state is equal (true) or not (false)

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

Initialises the response object to default properties.
public init ( ) : void
Результат void

initDefaultHeaders() защищенный Метод

Initializes the response with the default headers.
protected initDefaultHeaders ( ) : void
Результат void

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

Redirects to the passed URL by adding a 'Location' header and setting the appropriate status code, by default 301.
public redirect ( string $url, integer $code = 301 ) : void
$url string The URL to forward to
$code integer The status code to set
Результат void

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

Removes the header with the passed name.
public removeHeader ( string $name ) : void
$name string Name of the header to remove
Результат void

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

Reset the body stream
public resetBodyStream ( ) : void
Результат void

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

Resetss the stream resource pointing to body content.
public setBodyStream ( resource $bodyStream ) : void
$bodyStream resource The body content stream resource
Результат void

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

Binds the exception to the response.
public setException ( Exception $exception ) : void
$exception Exception The exception to bind.
Результат void

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

Resets all headers by given array
public setHeaders ( array $headers ) : void
$headers array The headers array
Результат void

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

Sets state of response
public setState ( integer $state ) : void
$state integer The state value
Результат void

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

Sets the http response status code
public setStatusCode ( integer $code ) : void
$code integer The status code to set
Результат void

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

Sets the status reason phrase
public setStatusReasonPhrase ( string $statusReasonPhrase ) : void
$statusReasonPhrase string The reason phrase
Результат void