Properties

$responseCodes

$responseCodes : array

Response codes & messages

Type

array

$version

$version : string

HTTP version for response, i.e. 1.0, 1.1, 2.0, 3.0, etc.

Type

string

$code

$code : integer

Response code

Type

integer

$message

$message : string

Response message

Type

string

$headers

$headers : array

Headers

Type

array

Methods

__construct()

__construct(array  $config = array()) 

Constructor

Instantiate the response object

Parameters

array $config

setVersion()

setVersion(float|string  $version) : \Pop\Http\AbstractResponse

Set the response version

Parameters

float|string $version

Returns

\Pop\Http\AbstractResponse

getVersion()

getVersion() : float|string

Get the response HTTP version

Returns

float|string

setCode()

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

Set the response code

Parameters

integer $code

Throws

\Pop\Http\Exception

Returns

\Pop\Http\AbstractResponse

getCode()

getCode() : string

Get the response code

Returns

string

setMessage()

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

Set the response message

Parameters

string $message

Returns

\Pop\Http\AbstractResponse

getMessage()

getMessage() : string

Get the response HTTP message

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

addHeader()

addHeader(\Pop\Mime\Part\Header|string  $header, string  $value = null) : \Pop\Http\AbstractHttp

Add a header

Parameters

\Pop\Mime\Part\Header|string $header
string $value

Returns

\Pop\Http\AbstractHttp

addHeaders()

addHeaders(array  $headers) : \Pop\Http\AbstractHttp

Add all headers

Parameters

array $headers

Returns

\Pop\Http\AbstractHttp

getHeader()

getHeader(string  $name) : mixed

Get a header

Parameters

string $name

Returns

mixed

getHeaderValue()

getHeaderValue(string  $name) : mixed

Get header value

Parameters

string $name

Returns

mixed

getHeaders()

getHeaders() : array

Get all headers

Returns

array

getHeadersAsArray()

getHeadersAsArray() : array

Get all header values as associative array

Returns

array

getHeadersAsString()

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

Get the response headers as a string

Parameters

boolean $status
string $eol

Returns

string

hasHeaders()

hasHeaders() : boolean

Determine if there are headers

Returns

boolean

hasHeader()

hasHeader(string  $name) : boolean

Has a header

Parameters

string $name

Returns

boolean

removeHeader()

removeHeader(string  $name) : \Pop\Http\AbstractHttp

Remove a header

Parameters

string $name

Returns

\Pop\Http\AbstractHttp

getBodyContent()

getBodyContent() : mixed

Get body content

Returns

mixed

hasBody()

hasBody() : boolean

Has a body

Returns

boolean

hasBodyContent()

hasBodyContent() : boolean

Has body content

Returns

boolean

decodeBodyContent()

decodeBodyContent(string  $body = null) : \Pop\Mime\Part\Body

Decode the body

Parameters

string $body

Returns

\Pop\Mime\Part\Body

__get()

__get(string  $name) : mixed

Magic method to get either the headers or body

Parameters

string $name

Returns

mixed

prepareBody()

prepareBody(boolean  $length = false, boolean  $mb = false) : string

Prepare response body

Parameters

boolean $length
boolean $mb

Returns

string

sendHeaders()

sendHeaders() : void

Send response headers

Throws

\Pop\Http\Server\Exception

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

__toString()

__toString() : string

Return entire response as a string

Returns

string

redirect()

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

Send redirect

Parameters

string $url
string $code
string $version

Throws

\Pop\Http\Server\Exception

redirectAndExit()

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

Send redirect and exit

Parameters

string $url
string $code
string $version

getMessageFromCode()

getMessageFromCode(integer  $code) : string

Get response message from code

Parameters

integer $code

Throws

\Pop\Http\Server\Exception

Returns

string