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

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

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

sendHeaders()

sendHeaders() : void

Send response headers

Throws

\Pop\Http\Exception

prepareBody()

prepareBody(boolean  $length = false) : string

Prepare response body

Parameters

boolean $length

Returns

string

send()

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

Send full response

Parameters

integer $code
array $headers
boolean $length

sendAndExit()

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

Send full response and exit

Parameters

integer $code
array $headers
boolean $length

__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