Class HttpSocketResponse
HTTP Response from HttpSocket.
- HttpSocketResponse implements ArrayAccess
Direct Subclasses
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Network/Http/HttpSocketResponse.php
Properties summary
-
$bodypublicBody contentstring -
$codepublicResponse codeinteger -
$contextpublicarrayContext data in the response. Contains SSL certificates for example.
-
$cookiespublicCookiesarray -
$headerspublicHeadersarray -
$httpVersionpublicHTTP versionstring -
$rawpublicPure raw contentstring -
$reasonPhrasepublicReason phrasestring
Method Summary
- __construct() publicConstructor
- __toString() publicInstance 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() protectedParses an array based header.
- _tokenEscapeChars() protectedGets escape chars according to RFC 2616 (HTTP 1.1 specs).
- _unescapeToken() protectedUnescapes a given $token according to RFC 2616 (HTTP 1.1 specs)
- body() publicBody content
- getHeader() publicGet header in case insensitive
- isOk() publicIf return is 200 (OK)
- isRedirect() publicIf return is a valid 3xx (Redirection)
- offsetExists() publicArrayAccess - Offset Exists
- offsetGet() publicArrayAccess - Offset Get
- offsetSet() publicArrayAccess - Offset Set
- offsetUnset() publicArrayAccess - Offset Unset
- parseCookies() publicParses cookies in response headers.
- parseResponse() publicParses the given message and breaks it down in parts.
Method Detail
__construct()source public
__construct( string $message null )
Constructor
Parameters
- string
$messageoptional null - Message to parse.
_decodeBody()source protected
_decodeBody( string $body , string|boolean $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.
- string|boolean
$encodingoptional 'chunked' - Can be false in case no encoding is being used, or a string representing the encoding.
Returns
mixedArray of response headers and body or false.
_decodeChunkedBody()source 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
mixedArray of response headers and body or false.
Throws
SocketException_parseHeader()source protected
_parseHeader( array $header )
Parses an array based header.
Parameters
- array
$header - Header as an indexed array (field => value)
Returns
arrayParsed header
_tokenEscapeChars()source protected
_tokenEscapeChars( boolean $hex true , array $chars null )
Gets escape chars according to RFC 2616 (HTTP 1.1 specs).
Parameters
- boolean
$hexoptional true - True to get them as HEX values, false otherwise.
- array
$charsoptional null - Characters to uescape.
Returns
arrayEscape chars
_unescapeToken()source 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
$charsoptional null - Characters to unescape.
Returns
stringUnescaped token
getHeader()source public
getHeader( string $name , array $headers null )
Get header in case insensitive
Parameters
- string
$name - Header name.
- array
$headersoptional null - Headers to format.
Returns
mixedString if header exists or null
offsetExists()source public
offsetExists( string $offset )
ArrayAccess - Offset Exists
Parameters
- string
$offset - Offset to check.
Returns
booleanImplementation of
ArrayAccess::offsetExists() offsetGet()source public
offsetGet( string $offset )
ArrayAccess - Offset Get
Parameters
- string
$offset - Offset to get.
Returns
mixedImplementation of
ArrayAccess::offsetGet() offsetSet()source public
offsetSet( string $offset , mixed $value )
ArrayAccess - Offset Set
Parameters
- string
$offset - Offset to set.
- mixed
$value - Value.
Implementation of
ArrayAccess::offsetSet() offsetUnset()source public
offsetUnset( string $offset )
ArrayAccess - Offset Unset
Parameters
- string
$offset - Offset to unset.
Implementation of
ArrayAccess::offsetUnset() parseCookies()source public
parseCookies( array $header )
Parses cookies in response headers.
Parameters
- array
$header - Header array containing one ore more 'Set-Cookie' headers.
Returns
mixedEither false on no cookies, or an array of cookies received.
parseResponse()source public
parseResponse( string $message )
Parses the given message and breaks it down in parts.
Parameters
- string
$message - Message to parse
Throws
SocketExceptionProperties detail
$contextsource
public array
Context data in the response. Contains SSL certificates for example.
array()
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.9/class-HttpSocketResponse.html