Properties

$responseCodes

$responseCodes : array

Response codes & messages

Type

array

$version

$version : string

HTTP version

Type

string

$code

$code : integer

Response code

Type

integer

$message

$message : string

Response message

Type

string

$headers

$headers : array

Response headers

Type

array

$body

$body : string

Response body

Type

string

Methods

__construct()

__construct(array  $config = array()) 

Constructor

Instantiate the response object

Parameters

array $config

Throws

\Pop\Http\Exception

parse()

parse(string  $response, string  $mode = 'r', array  $options = array()) : \Pop\Http\Response

Parse a response and create a new response object, either from a URL or a full response string

Parameters

string $response
string $mode
array $options

Throws

\Pop\Http\Exception

Returns

\Pop\Http\Response

redirect()

redirect(string  $url, string  $code = '302', string  $version = '1.1') : void

Send redirect

Parameters

string $url
string $code
string $version

Throws

\Pop\Http\Exception

getMessageFromCode()

getMessageFromCode(integer  $code) : string

Get response message from code

Parameters

integer $code

Throws

\Pop\Http\Exception

Returns

string

encodeBody()

encodeBody(string  $body, string  $encode = 'gzip') : string

Encode the body data

Parameters

string $body
string $encode

Throws

\Pop\Http\Exception

Returns

string

decodeBody()

decodeBody(string  $body, string  $decode = 'gzip') : string

Decode the body data

Parameters

string $body
string $decode

Throws

\Pop\Http\Exception

Returns

string

decodeChunkedBody()

decodeChunkedBody(string  $body) : string

Decode a chunked transfer-encoded body and return the decoded text

Parameters

string $body

Returns

string

isSuccess()

isSuccess() : boolean

Determine if the response is a success

Returns

boolean

isRedirect()

isRedirect() : boolean

Determine if the response is a redirect

Returns

boolean

isError()

isError() : boolean

Determine if the response is an error

Returns

boolean

isClientError()

isClientError() : boolean

Determine if the response is a client error

Returns

boolean

isServerError()

isServerError() : boolean

Determine if the response is a server error

Returns

boolean

getVersion()

getVersion() : float

Get the response version

Returns

float

getCode()

getCode() : integer

Get the response code

Returns

integer

getMessage()

getMessage() : string

Get the response message

Returns

string

getBody()

getBody() : string

Get the response body

Returns

string

getHeaders()

getHeaders() : array

Get the response headers

Returns

array

getHeader()

getHeader(string  $name) : string

Get the response header

Parameters

string $name

Returns

string

getHeadersAsString()

getHeadersAsString(boolean  $status = true, string  $eol = "\n") : string

Get the response headers as a string

Parameters

boolean $status
string $eol

Returns

string

setVersion()

setVersion(float  $version = 1.1) : \Pop\Http\Response

Set the response version

Parameters

float $version

Returns

\Pop\Http\Response

setCode()

setCode(integer  $code = 200) : \Pop\Http\Response

Set the response code

Parameters

integer $code

Throws

\Pop\Http\Exception

Returns

\Pop\Http\Response

setMessage()

setMessage(string  $message = null) : \Pop\Http\Response

Set the response message

Parameters

string $message

Returns

\Pop\Http\Response

setBody()

setBody(string  $body = null) : \Pop\Http\Response

Set the response body

Parameters

string $body

Returns

\Pop\Http\Response

setHeader()

setHeader(string  $name, string  $value) : \Pop\Http\Response

Set a response header

Parameters

string $name
string $value

Throws

\Pop\Http\Exception

Returns

\Pop\Http\Response

setHeaders()

setHeaders(array  $headers) : \Pop\Http\Response

Set response headers

Parameters

array $headers

Throws

\Pop\Http\Exception

Returns

\Pop\Http\Response

setSslHeaders()

setSslHeaders() : \Pop\Http\Response

Set SSL headers to fix file cache issues over SSL in certain browsers.

Returns

\Pop\Http\Response

sendHeaders()

sendHeaders() : void

Send headers

Throws

\Pop\Http\Exception

send()

send(integer  $code = null, array  $headers = null) : void

Send response

Parameters

integer $code
array $headers

sendAndExit()

sendAndExit(integer  $code = null, array  $headers = null) : void

Send response and exit

Parameters

integer $code
array $headers

__get()

__get(string  $name) : mixed

Magic method to get a value from the headers

Parameters

string $name

Returns

mixed

__toString()

__toString() : string

Return entire response as a string

Returns

string