Inheritance diagram for HttpSocket:

Public Member Functions | |
| __construct ($config=array()) | |
| __tokenEscapeChars ($hex=true, $chars=null) | |
| buildCookies ($cookies) | |
| buildHeader ($header, $mode= 'standard') | |
| buildRequestLine ($request=array(), $versionToken= 'HTTP/1.1') | |
| buildUri ($uri=array(), $uriTemplate= '%scheme://%user:%pass @%host:%port/%path?%query#%fragment') | |
| configUri ($uri=null) | |
| decodeBody ($body, $encoding= 'chunked') | |
| decodeChunkedBody ($body) | |
| delete ($uri=null, $data=array(), $request=array()) | |
| escapeToken ($token, $chars=null) | |
| get ($uri=null, $query=array(), $request=array()) | |
| httpSerialize ($data=array()) | |
| loadCookies () | |
| parseCookies ($header) | |
| parseHeader ($header) | |
| parseQuery ($query) | |
| parseResponse ($message) | |
| parseUri ($uri=null, $base=array()) | |
| post ($uri=null, $data=array(), $request=array()) | |
| put ($uri=null, $data=array(), $request=array()) | |
| request ($request=array()) | |
| reset ($full=true) | |
| saveCookies () | |
| unescapeToken ($token, $chars=null) | |
| url ($url=null, $uriTemplate=null) | |
Public Attributes | |
| $config | |
| $description = 'HTTP-based DataSource Interface' | |
| $lineBreak = "\r\n" | |
| $quirksMode = false | |
| $request | |
| $response | |
Definition at line 34 of file http_socket.php.
| HttpSocket::__construct | ( | $ | config = array() |
) |
Build an HTTP Socket using the specified configuration.
| array | $config Configuration |
Reimplemented from CakeSocket.
Definition at line 144 of file http_socket.php.
References $config, __construct(), config(), configUri(), Set::merge(), and request().
| HttpSocket::__tokenEscapeChars | ( | $ | hex = true, |
|
| $ | chars = null | |||
| ) |
Gets escape chars according to RFC 2616 (HTTP 1.1 specs).
| boolean | $hex true to get them as HEX values, false otherwise |
Definition at line 949 of file http_socket.php.
| HttpSocket::buildCookies | ( | $ | cookies | ) |
undocumented function
| unknown | $cookies |
Definition at line 889 of file http_socket.php.
Referenced by request().
| HttpSocket::buildHeader | ( | $ | header, | |
| $ | mode = 'standard' | |||
| ) |
Builds the header.
| array | $header Header to build |
Definition at line 769 of file http_socket.php.
Referenced by parseResponse(), and request().
| HttpSocket::buildRequestLine | ( | $ | request = array(), |
|
| $ | versionToken = 'HTTP/1.1' | |||
| ) |
Builds a request line according to HTTP/1.1 specs. Activate quirks mode to work outside specs.
| array | $request Needs to contain a 'uri' key. Should also contain a 'method' key, otherwise defaults to GET. | |
| string | $versionToken The version token to use, defaults to HTTP/1.1 |
Definition at line 720 of file http_socket.php.
Referenced by request().
| HttpSocket::buildUri | ( | $ | uri = array(), |
|
| $ | uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment' | |||
| ) |
Takes a $uri array and turns it into a fully qualified URL string
| array | $uri A $uri array, or uses $this->config if left empty | |
| string | $uriTemplate The Uri template/format to use |
Definition at line 552 of file http_socket.php.
References CakeSocket::host().
| HttpSocket::configUri | ( | $ | uri = null |
) |
Parses and sets the specified URI into current request configuration.
| mixed | $uri URI (see parseUri()) |
Definition at line 519 of file http_socket.php.
References $config, config(), CakeSocket::host(), Set::merge(), parseUri(), and request().
Referenced by __construct(), and request().
| HttpSocket::decodeBody | ( | $ | body, | |
| $ | 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.
| string | $body A string continaing the body to decode | |
| mixed | $encoding Can be false in case no encoding is being used, or a string representing the encoding |
Definition at line 433 of file http_socket.php.
Referenced by parseResponse().
| HttpSocket::decodeChunkedBody | ( | $ | body | ) |
Decodes a chunked message $body and returns either an array with the keys 'body' and 'header' or false as a result.
| string | $body A string continaing the chunked body to decode |
Definition at line 458 of file http_socket.php.
References __(), and parseHeader().
| HttpSocket::delete | ( | $ | uri = null, |
|
| $ | data = array(), |
|||
| $ | request = array() | |||
| ) |
Issues a DELETE request to the specified URI, query, and request.
| mixed | $uri URI to request (see parseUri()) | |
| array | $query Query to append to URI | |
| array | $request An indexed array with indexes such as 'method' or uri |
Definition at line 324 of file http_socket.php.
References $request, Set::merge(), and request().
| HttpSocket::escapeToken | ( | $ | token, | |
| $ | chars = null | |||
| ) |
Escapes a given $token according to RFC 2616 (HTTP 1.1 specs)
| string | $token Token to escape |
Definition at line 936 of file http_socket.php.
| HttpSocket::get | ( | $ | uri = null, |
|
| $ | query = array(), |
|||
| $ | request = array() | |||
| ) |
Issues a GET request to the specified URI, query, and request.
| mixed | $uri URI to request (see parseUri()) | |
| array | $query Query to append to URI | |
| array | $request An indexed array with indexes such as 'method' or uri |
Definition at line 274 of file http_socket.php.
References $request, buildUri(), Set::merge(), parseUri(), and request().
| HttpSocket::httpSerialize | ( | $ | data = array() |
) |
Serializes an array for transport.
| array | $data Data to serialize |
Definition at line 753 of file http_socket.php.
Referenced by request().
| HttpSocket::loadCookies | ( | ) |
| HttpSocket::parseCookies | ( | $ | header | ) |
undocumented function
| unknown | $header |
Definition at line 848 of file http_socket.php.
Referenced by parseResponse().
| HttpSocket::parseHeader | ( | $ | header | ) |
Parses an array based header.
| array | $header Header as an indexed array (field => value) |
Definition at line 798 of file http_socket.php.
Referenced by decodeChunkedBody(), parseResponse(), and request().
| HttpSocket::parseQuery | ( | $ | query | ) |
This function can be thought of as a reverse to PHP5's http_build_query(). It takes a given query string and turns it into an array and supports nesting by using the php bracket syntax. So this menas you can parse queries like:
A leading '?' mark in $query is optional and does not effect the outcome of this function. For the complete capabilities of this implementation take a look at HttpSocketTest::testParseQuery()
| mixed | $query A query string to parse into an array or an array to return directly "as is" |
Definition at line 663 of file http_socket.php.
| HttpSocket::parseResponse | ( | $ | message | ) |
Parses the given message and breaks it down in parts.
| string | $message Message to parse |
Definition at line 370 of file http_socket.php.
References $response, buildHeader(), decodeBody(), parseCookies(), and parseHeader().
Referenced by request().
| HttpSocket::parseUri | ( | $ | uri = null, |
|
| $ | base = array() | |||
| ) |
Parses the given URI and breaks it down into pieces as an indexed array with elements such as 'scheme', 'port', 'query'.
| string | $uri URI to parse | |
| mixed | $base If true use default URI config, otherwise indexed array to set 'scheme', 'host', 'port', etc. |
Definition at line 599 of file http_socket.php.
Referenced by configUri(), get(), request(), and url().
| HttpSocket::post | ( | $ | uri = null, |
|
| $ | data = array(), |
|||
| $ | request = array() | |||
| ) |
Issues a POST request to the specified URI, query, and request.
| mixed | $uri URI to request (see parseUri()) | |
| array | $query Query to append to URI | |
| array | $request An indexed array with indexes such as 'method' or uri |
Definition at line 298 of file http_socket.php.
References $request, Set::merge(), and request().
| HttpSocket::put | ( | $ | uri = null, |
|
| $ | data = array(), |
|||
| $ | request = array() | |||
| ) |
Issues a PUT request to the specified URI, query, and request.
| mixed | $uri URI to request (see parseUri()) | |
| array | $query Query to append to URI | |
| array | $request An indexed array with indexes such as 'method' or uri |
Definition at line 311 of file http_socket.php.
References $request, Set::merge(), and request().
| HttpSocket::request | ( | $ | request = array() |
) |
Issue the specified request.
| mixed | $request Either an URI string, or an array defining host/uri |
Definition at line 163 of file http_socket.php.
References $request, $response, buildCookies(), buildHeader(), buildRequestLine(), close(), config(), configUri(), CakeSocket::disconnect(), CakeSocket::host(), httpSerialize(), Set::merge(), parseHeader(), parseResponse(), parseUri(), CakeSocket::read(), reset(), url(), and CakeSocket::write().
Referenced by __construct(), configUri(), delete(), get(), post(), put(), and url().
| HttpSocket::reset | ( | $ | full = true |
) |
Resets the state of this HttpSocket instance to it's initial state (before Object::__construct got executed) or does the same thing partially for the request and the response property only.
| boolean | $full If set to false only HttpSocket::response and HttpSocket::request are reseted |
Reimplemented from CakeSocket.
Definition at line 977 of file http_socket.php.
Referenced by request().
| HttpSocket::saveCookies | ( | ) |
| HttpSocket::unescapeToken | ( | $ | token, | |
| $ | chars = null | |||
| ) |
Unescapes a given $token according to RFC 2616 (HTTP 1.1 specs)
| string | $token Token to unescape |
Definition at line 923 of file http_socket.php.
| HttpSocket::url | ( | $ | url = null, |
|
| $ | uriTemplate = null | |||
| ) |
undocumented function
| unknown | $url | |
| unknown | $uriTemplate |
Definition at line 336 of file http_socket.php.
References $url, buildUri(), config(), CakeSocket::host(), parseUri(), and request().
Referenced by request().
| HttpSocket::$config |
Initial value:
array(
'persistent' => false,
'host' => 'localhost',
'protocol' => 'tcp',
'port' => 80,
'timeout' => 30,
'request' => array(
'uri' => array(
'scheme' => 'http',
'host' => 'localhost',
'port' => 80
),
'auth' => array(
'method' => 'Basic',
'user' => null,
'pass' => null
),
'cookies' => array()
)
)
Reimplemented from CakeSocket.
Definition at line 111 of file http_socket.php.
Referenced by __construct(), and configUri().
| HttpSocket::$description = 'HTTP-based DataSource Interface' |
| HttpSocket::$lineBreak = "\r\n" |
Definition at line 137 of file http_socket.php.
| HttpSocket::$quirksMode = false |
Definition at line 49 of file http_socket.php.
| HttpSocket::$request |
Initial value:
array(
'method' => 'GET',
'uri' => array(
'scheme' => 'http',
'host' => null,
'port' => 80,
'user' => null,
'pass' => null,
'path' => null,
'query' => null,
'fragment' => null
),
'auth' => array(
'method' => 'Basic',
'user' => null,
'pass' => null
),
'version' => '1.1',
'body' => '',
'line' => null,
'header' => array(
'Connection' => 'close',
'User-Agent' => 'CakePHP'
),
'raw' => null,
'cookies' => array()
)
Definition at line 56 of file http_socket.php.
Referenced by delete(), get(), post(), put(), and request().
| HttpSocket::$response |
Initial value:
array(
'raw' => array(
'status-line' => null,
'header' => null,
'body' => null,
'response' => null
),
'status' => array(
'http-version' => null,
'code' => null,
'reason-phrase' => null
),
'header' => array(),
'body' => '',
'cookies' => array()
)
Definition at line 89 of file http_socket.php.
Referenced by parseResponse(), and request().
1.4.7