PHP Class AppserverIo\Appserver\ServletEngine\Http\Response

Inheritance: implements AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface
Afficher le fichier Open project: appserver-io/appserver Class Usage Examples

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
initDefaultHeaders ( ) : void Initializes the response with the default headers.

Method Details

addCookie() public méthode

Adds a cookie.
public addCookie ( AppserverIo\Psr\HttpMessage\CookieInterface $cookie ) : void
$cookie AppserverIo\Psr\HttpMessage\CookieInterface The cookie instance to add
Résultat void

addHeader() public méthode

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
Résultat void

appendBodyStream() public méthode

Appends the content.
public appendBodyStream ( string $content ) : void
$content string The content to append
Résultat void

copyBodyStream() public méthode

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
Résultat integer The total number of bytes copied

getBodyContent() public méthode

Return content
public getBodyContent ( ) : string
Résultat string $content

getBodyStream() public méthode

Returns the body stream as a resource.
public getBodyStream ( ) : resource
Résultat resource The body stream

getCookie() public méthode

Returns the cookie with the a cookie
public getCookie ( string $cookieName ) : mixed
$cookieName string Name of the cookie to be checked
Résultat mixed The cookie instance or an array of cookie instances

getCookies() public méthode

Returns the cookies.
public getCookies ( ) : array
Résultat array The cookies

getException() public méthode

Returns the exception bound to the response.
public getException ( ) : Exception | null
Résultat Exception | null The exception

getHeader() public méthode

Returns header by given name.
public getHeader ( string $name ) : mixed
$name string The header name to get
Résultat mixed Usually a string, but can also be an array if we request the Set-Cookie header

getHeaders() public méthode

Returns all headers as array
public getHeaders ( ) : array
Résultat array

getHeadersAsString() public méthode

Returns the headers as string
public getHeadersAsString ( ) : string
Résultat string

getState() public méthode

Returns the current state
public getState ( ) : integer
Résultat integer

getStatusCode() public méthode

Returns the response status code
public getStatusCode ( ) : integer
Résultat integer

getStatusReasonPhrase() public méthode

Returns the status phrase based on the status code
public getStatusReasonPhrase ( ) : string
Résultat string

getVersion() public méthode

Returns the http version of the response
public getVersion ( ) : string
Résultat string

hasCookie() public méthode

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
Résultat boolean TRUE if the response already has the cookie, else FALSE

hasException() public méthode

Queries whether the response contains an exception or not.
public hasException ( ) : boolean
Résultat boolean TRUE if an exception has been attached, else FALSE

hasHeader() public méthode

Check's if header exists by given name
public hasHeader ( string $name ) : boolean
$name string The header name to check
Résultat boolean

hasState() public méthode

Compares current state with given state
public hasState ( integer $state ) : boolean
$state integer The state to compare with
Résultat boolean Whether state is equal (true) or not (false)

init() public méthode

Initialises the response object to default properties.
public init ( ) : void
Résultat void

initDefaultHeaders() protected méthode

Initializes the response with the default headers.
protected initDefaultHeaders ( ) : void
Résultat void

redirect() public méthode

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
Résultat void

removeHeader() public méthode

Removes the header with the passed name.
public removeHeader ( string $name ) : void
$name string Name of the header to remove
Résultat void

resetBodyStream() public méthode

Reset the body stream
public resetBodyStream ( ) : void
Résultat void

setBodyStream() public méthode

Resetss the stream resource pointing to body content.
public setBodyStream ( resource $bodyStream ) : void
$bodyStream resource The body content stream resource
Résultat void

setException() public méthode

Binds the exception to the response.
public setException ( Exception $exception ) : void
$exception Exception The exception to bind.
Résultat void

setHeaders() public méthode

Resets all headers by given array
public setHeaders ( array $headers ) : void
$headers array The headers array
Résultat void

setState() public méthode

Sets state of response
public setState ( integer $state ) : void
$state integer The state value
Résultat void

setStatusCode() public méthode

Sets the http response status code
public setStatusCode ( integer $code ) : void
$code integer The status code to set
Résultat void

setStatusReasonPhrase() public méthode

Sets the status reason phrase
public setStatusReasonPhrase ( string $statusReasonPhrase ) : void
$statusReasonPhrase string The reason phrase
Résultat void