class SS_HTTPResponse (View source)

Represents a response returned by a controller.

Methods

__construct(string $body = null, int $statusCode = null, string $statusDescription = null)

Create a new HTTP response

$this
setStatusCode(int $code, string $description = null)

No description

$this
setStatusDescription(string $description)

The text to be given alongside the status code ("reason phrase").

int
getStatusCode()

No description

string
getStatusDescription()

No description

bool
isError()

Returns true if this HTTP response is in error

$this
setBody(string $body)

No description

null|string
getBody()

No description

$this
addHeader(string $header, string $value)

Add a HTTP header to the response, replacing any header of the same name.

getHeader(string $header, $anyCase = false)

Return the HTTP header of the given name.

array
getHeaders()

No description

$this
removeHeader(string $header)

Remove an existing HTTP header by its name, e.g. "Content-Type".

$this
redirect(string $dest, int $code = 302)

No description

output()

Send this HTTPReponse to the browser

bool
isFinished()

Returns true if this response is "finished", that is, no more script execution should be done.

Details

__construct(string $body = null, int $statusCode = null, string $statusDescription = null)

Create a new HTTP response

Parameters

string $body

The body of the response

int $statusCode

The numeric status code - 200, 404, etc

string $statusDescription

The text to be given alongside the status code. See {@link setStatusCode()} for more information.

$this setStatusCode(int $code, string $description = null)

Parameters

int $code
string $description

Optional. See {@link setStatusDescription()}. No newlines are allowed in the description. If omitted, will default to the standard HTTP description for the given $code value (see {@link $status_codes}).

Return Value

$this

$this setStatusDescription(string $description)

The text to be given alongside the status code ("reason phrase").

Caution: Will be overwritten by {@link setStatusCode()}.

Parameters

string $description

Return Value

$this

int getStatusCode()

Return Value

int

string getStatusDescription()

Return Value

string

Description for a HTTP status code

bool isError()

Returns true if this HTTP response is in error

Return Value

bool

$this setBody(string $body)

Parameters

string $body

Return Value

$this

null|string getBody()

Return Value

null|string

$this addHeader(string $header, string $value)

Add a HTTP header to the response, replacing any header of the same name.

Parameters

string $header

Example: "Content-Type"

string $value

Example: "text/xml"

Return Value

$this

getHeader(string $header, $anyCase = false)

Return the HTTP header of the given name.

Parameters

string $header
$anyCase

array getHeaders()

Return Value

array

$this removeHeader(string $header)

Remove an existing HTTP header by its name, e.g. "Content-Type".

Parameters

string $header

Return Value

$this

$this redirect(string $dest, int $code = 302)

Parameters

string $dest
int $code

Return Value

$this

output()

Send this HTTPReponse to the browser

bool isFinished()

Returns true if this response is "finished", that is, no more script execution should be done.

Specifically, returns true if a redirect has already been requested

Return Value

bool