CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.9 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.9
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper
  • None

Classes

  • BasicAuthentication
  • DigestAuthentication
  • HttpResponse
  • HttpSocket
  • HttpSocketResponse

Class HttpSocketResponse

HTTP Response from HttpSocket.

HttpSocketResponse implements ArrayAccess
Direct Subclasses
  • HttpResponse
Package: Cake\Network\Http
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Network/Http/HttpSocketResponse.php

Properties summary

  • $body public
    string
    Body content
  • $code public
    integer
    Response code
  • $context public
    array

    Context data in the response. Contains SSL certificates for example.

  • $cookies public
    array
    Cookies
  • $headers public
    array
    Headers
  • $httpVersion public
    string
    HTTP version
  • $raw public
    string
    Pure raw content
  • $reasonPhrase public
    string
    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)
  • isRedirect() public
    If return is a valid 3xx (Redirection)
  • 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
Message to parse.

__toString() public ¶

__toString( )

Instance as string

Returns
string

_decodeBody() 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 $encoding optional 'chunked'
Can be false in case no encoding is being used, or a string representing the encoding.
Returns
mixed
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
mixed
Array of response headers and body or false.
Throws
SocketException

_parseHeader() protected ¶

_parseHeader( array $header )

Parses an array based header.

Parameters
array $header
Header as an indexed array (field => value)
Returns
array
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
Characters to uescape.
Returns
array
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
Characters to unescape.
Returns
string
Unescaped token

body() public ¶

body( )

Body content

Returns
string

getHeader() public ¶

getHeader( string $name , array $headers = null )

Get header in case insensitive

Parameters
string $name
Header name.
array $headers optional null
Headers to format.
Returns
mixed
String if header exists or null

isOk() public ¶

isOk( )

If return is 200 (OK)

Returns
boolean

isRedirect() public ¶

isRedirect( )

If return is a valid 3xx (Redirection)

Returns
boolean

offsetExists() public ¶

offsetExists( string $offset )

ArrayAccess - Offset Exists

Parameters
string $offset
Offset to check.
Returns
boolean
Implementation of
ArrayAccess::offsetExists()

offsetGet() public ¶

offsetGet( string $offset )

ArrayAccess - Offset Get

Parameters
string $offset
Offset to get.
Returns
mixed
Implementation of
ArrayAccess::offsetGet()

offsetSet() public ¶

offsetSet( string $offset , mixed $value )

ArrayAccess - Offset Set

Parameters
string $offset
Offset to set.
mixed $value
Value.
Implementation of
ArrayAccess::offsetSet()

offsetUnset() public ¶

offsetUnset( string $offset )

ArrayAccess - Offset Unset

Parameters
string $offset
Offset to unset.
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
mixed
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
Throws
SocketException

Properties detail

$body ¶

public string

Body content

''

$code ¶

public integer

Response code

$context ¶

public array

Context data in the response. Contains SSL certificates for example.

array()

$cookies ¶

public array

Cookies

array()

$headers ¶

public array

Headers

array()

$httpVersion ¶

public string

HTTP version

'HTTP/1.1'

$raw ¶

public string

Pure raw content

''

$reasonPhrase ¶

public string

Reason phrase

''
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs