Class HttpResponse
HTTP Response from HttpSocket.
- HttpResponse implements ArrayAccess
Copyright: Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Network/Http/HttpResponse.php
Properties summary
-
$body
publicstring
Body content -
$code
publicinteger
Response code -
$cookies
publicarray
Cookies -
$headers
publicarray
Headers -
$httpVersion
publicstring
HTTP version -
$raw
publicstring
Pure raw content -
$reasonPhrase
publicstring
Reason phrase
Method Summary
-
__construct() public
Constructor -
__toString() public
Instance as string -
_decodeBody() protected
Generic function to decode a $body with a given $encoding. Returns either an array with the keys 'body' and 'header' or false on failure.
-
_decodeChunkedBody() protected
Decodes a chunked message $body and returns either an array with the keys 'body' and 'header' or false as a result.
-
_parseHeader() protected
Parses an array based header. -
_tokenEscapeChars() protected
Gets escape chars according to RFC 2616 (HTTP 1.1 specs). -
_unescapeToken() protected
Unescapes a given $token according to RFC 2616 (HTTP 1.1 specs) -
body() public
Body content -
getHeader() public
Get header in case insensitive -
isOk() public
If return is 200 (OK) -
offsetExists() public
ArrayAccess - Offset Exists -
offsetGet() public
ArrayAccess - Offset Get -
offsetSet() public
ArrayAccess - Offset Set -
offsetUnset() public
ArrayAccess - Offset Unset -
parseCookies() public
Parses cookies in response headers. -
parseResponse() public
Parses the given message and breaks it down in parts.
Method Detail
__construct() public ¶
__construct( string $message = null )
Constructor
Parameters
- string $message optional null
_decodeBody() protected ¶
_decodeBody( string $body , mixed $encoding = 'chunked' )
Generic function to decode a $body with a given $encoding. Returns either an array with the keys 'body' and 'header' or false on failure.
Parameters
- string $body
- A string containing the body to decode.
- mixed $encoding optional 'chunked'
- Can be false in case no encoding is being used, or a string representing the encoding.
Returns
Array of response headers and body or false.
_decodeChunkedBody() protected ¶
_decodeChunkedBody( string $body )
Decodes a chunked message $body and returns either an array with the keys 'body' and 'header' or false as a result.
Parameters
- string $body
- A string containing the chunked body to decode.
Returns
Array of response headers and body or false.
Throws
_parseHeader() protected ¶
_parseHeader( array $header )
Parses an array based header.
Parameters
- array $header
- Header as an indexed array (field => value)
Returns
Parsed header
_tokenEscapeChars() protected ¶
_tokenEscapeChars( boolean $hex = true , array $chars = null )
Gets escape chars according to RFC 2616 (HTTP 1.1 specs).
Parameters
- boolean $hex optional true
- true to get them as HEX values, false otherwise
- array $chars optional null
Returns
Escape chars
_unescapeToken() protected ¶
_unescapeToken( string $token , array $chars = null )
Unescapes a given $token according to RFC 2616 (HTTP 1.1 specs)
Parameters
- string $token
- Token to unescape
- array $chars optional null
Returns
Unescaped token
getHeader() public ¶
getHeader( string $name , array $headers = null )
Get header in case insensitive
Parameters
- string $name
- Header name
- array $headers optional null
Returns
String if header exists or null
offsetExists() public ¶
offsetExists( mixed $offset )
ArrayAccess - Offset Exists
Parameters
- mixed $offset
Returns
Implementation of
ArrayAccess::offsetExists()
offsetGet() public ¶
offsetGet( mixed $offset )
ArrayAccess - Offset Get
Parameters
- mixed $offset
Returns
Implementation of
ArrayAccess::offsetGet()
offsetSet() public ¶
offsetSet( mixed $offset , mixed $value )
ArrayAccess - Offset Set
Parameters
- mixed $offset
- mixed $value
Implementation of
ArrayAccess::offsetSet()
offsetUnset() public ¶
offsetUnset( mixed $offset )
ArrayAccess - Offset Unset
Parameters
- mixed $offset
Implementation of
ArrayAccess::offsetUnset()
parseCookies() public ¶
parseCookies( array $header )
Parses cookies in response headers.
Parameters
- array $header
- Header array containing one ore more 'Set-Cookie' headers.
Returns
Either false on no cookies, or an array of cookies received.
parseResponse() public ¶
parseResponse( string $message )
Parses the given message and breaks it down in parts.
Parameters
- string $message
- Message to parse