class RestfulService_Response extends SS_HTTPResponse (View source)

Properties

protected static array $status_codes from  SS_HTTPResponse
protected static array $redirect_codes from  SS_HTTPResponse
protected int $statusCode from  SS_HTTPResponse
protected string $statusDescription from  SS_HTTPResponse
protected array $headers

HTTP Headers like "Content-Type: text/xml"

from  SS_HTTPResponse
protected string $body from  SS_HTTPResponse
protected $simpleXML
protected RestfulService_Response|false $cachedResponse

Methods

public
__construct(string $body, int $statusCode = 200, $headers = null)

Create a new HTTP response

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

No description

public
$this
setStatusDescription(string $description)

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

public
int
getStatusCode()

No description

public
string
getStatusDescription()

No description

public
bool
isError()

Returns true if this HTTP response is in error

public
$this
setBody(string $body)

No description

public
null|string
getBody()

No description

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

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

public
getHeader(string $header, $anyCase = false)

Return the HTTP header of the given name.

public
array
getHeaders()

No description

public
$this
removeHeader(string $header)

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

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

No description

public
output()

Send this HTTPReponse to the browser

public
bool
isFinished()

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

public
simpleXML()

No description

public
getCachedResponse()

get the cached response object. This allows you to access the cached eaders, not just the cached body.

public
string|false
getCachedBody()

No description

public
setCachedBody($content) deprecated

No description

public
setCachedResponse($response)

No description

public
xpath($xpath)

Return an array of xpath matches

public
xpath_one($xpath)

Return the first xpath match

Details

__construct(string $body, int $statusCode = 200, $headers = null)

Create a new HTTP response

Parameters

string $body

The body of the response

int $statusCode

The numeric status code - 200, 404, etc

$headers

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

No description

Parameters

int $code
string $description

Optional. See setStatusDescription(). No newlines are allowed in the description. If omitted, will default to the standard HTTP description for the given $code value (see $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 setStatusCode().

Parameters

string $description

Return Value

$this

int getStatusCode()

No description

Return Value

int

string getStatusDescription()

No description

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)

No description

Parameters

string $body

Return Value

$this

null|string getBody()

No description

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()

No description

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)

No description

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

simpleXML()

No description

RestfulService_Response|false getCachedResponse()

get the cached response object. This allows you to access the cached eaders, not just the cached body.

Return Value

RestfulService_Response|false

The cached response object

string|false getCachedBody()

No description

Return Value

string|false

setCachedBody($content) deprecated

deprecated since version 4.0

No description

Parameters

$content

setCachedResponse($response)

No description

Parameters

$response

xpath($xpath)

Return an array of xpath matches

Parameters

$xpath

xpath_one($xpath)

Return the first xpath match

Parameters

$xpath