Definition at line 40 of file Socket.php.
HTTP_Request2_Adapter_Socket::addAuthorizationHeader |
( |
& |
$headers, |
|
|
|
$requestHost, |
|
|
|
$requestUrl |
|
) |
| |
|
protected |
Adds 'Authorization' header (if needed) to request headers array
- Parameters
-
array | &$headers | request headers |
string | $requestHost | request host (needed for digest authentication) |
string | $requestUrl | request URL (needed for digest authentication) |
- Exceptions
-
Definition at line 729 of file Socket.php.
HTTP_Request2_Adapter_Socket::addProxyAuthorizationHeader |
( |
& |
$headers, |
|
|
|
$requestUrl |
|
) |
| |
|
protected |
Adds 'Proxy-Authorization' header (if needed) to request headers array
- Parameters
-
array | &$headers | request headers |
string | $requestUrl | request URL (needed for digest authentication) |
- Exceptions
-
Definition at line 774 of file Socket.php.
Checks whether current connection may be reused or should be closed
- Parameters
-
boolean | $requestKeepAlive | whether connection could be persistent in the first place |
HTTP_Request2_Response | $response | response object to check |
- Returns
- boolean
Definition at line 372 of file Socket.php.
HTTP_Request2_Adapter_Socket::connect |
( |
| ) |
|
|
protected |
Connects to the remote server
- Returns
- bool whether the connection can be persistent
- Exceptions
-
Definition at line 195 of file Socket.php.
HTTP_Request2_Adapter_Socket::createDigestResponse |
( |
|
$user, |
|
|
|
$password, |
|
|
|
$url, |
|
|
& |
$challenge |
|
) |
| |
|
protected |
Creates a value for [Proxy-]Authorization header when using digest authentication
- Parameters
-
string | $user | user name |
string | $password | password |
string | $url | request URL |
array | &$challenge | digest challenge parameters |
- Returns
- string value of [Proxy-]Authorization request header http://tools.ietf.org/html/rfc2617#section-3.2.2
Definition at line 683 of file Socket.php.
HTTP_Request2_Adapter_Socket::disconnect |
( |
| ) |
|
|
protected |
Disconnects from the remote server
Definition at line 395 of file Socket.php.
HTTP_Request2_Adapter_Socket::establishTunnel |
( |
| ) |
|
|
protected |
Establishes a tunnel to a secure remote server via HTTP CONNECT request
This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP sees that we are connected to a proxy server (duh!) rather than the server that presents its certificate.
HTTP_Request2_Exception
Definition at line 344 of file Socket.php.
Handles HTTP redirection
This method will throw an Exception if redirect to a non-HTTP(S) location is attempted, also if number of redirects performed already is equal to 'max_redirects' configuration parameter.
- Parameters
-
- Returns
- HTTP_Request2_Response Response from a new location
- Exceptions
-
Definition at line 416 of file Socket.php.
HTTP_Request2_Adapter_Socket::parseDigestChallenge |
( |
|
$headerValue | ) |
|
|
protected |
Extracts digest method challenge from (WWW|Proxy)-Authenticate header value
There is a problem with implementation of RFC 2617: several of the parameters are defined as quoted-string there and thus may contain backslash escaped double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as just value of quoted-string X without surrounding quotes, it doesn't speak about removing backslash escaping.
Now realm parameter is user-defined and human-readable, strange things happen when it contains quotes:
- Apache allows quotes in realm, but apparently uses realm value without backslashes for digest computation
- Squid allows (manually escaped) quotes there, but it is impossible to authorize with either escaped or unescaped quotes used in digest, probably it can't parse the response (?)
- Both IE and Firefox display realm value with backslashes in the password popup and apparently use the same value for digest
HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in quoted-string handling, unfortunately that means failure to authorize sometimes
- Parameters
-
string | $headerValue | value of WWW-Authenticate or Proxy-Authenticate header |
- Returns
- mixed associative array with challenge parameters, false if no challenge is present in header value
- Exceptions
-
Definition at line 600 of file Socket.php.
HTTP_Request2_Adapter_Socket::prepareHeaders |
( |
| ) |
|
|
protected |
Creates the string with the Request-Line and request headers
- Returns
- string
- Exceptions
-
Definition at line 820 of file Socket.php.
HTTP_Request2_Adapter_Socket::readChunked |
( |
|
$bufferSize | ) |
|
|
protected |
Reads a part of response body encoded with chunked Transfer-Encoding
- Parameters
-
int | $bufferSize | buffer size to use for reading |
- Returns
- string
- Exceptions
-
Definition at line 1093 of file Socket.php.
HTTP_Request2_Adapter_Socket::readResponse |
( |
| ) |
|
|
protected |
HTTP_Request2_Adapter_Socket::sendRequest |
( |
HTTP_Request2 |
$request | ) |
|
Checks whether another request should be performed with proxy digest auth
Several conditions should be satisfied for it to return true:
- response status should be 407
- proxy auth credentials should be set in the request object
- response should contain Proxy-Authenticate header with digest challenge
- there is either no challenge stored for this proxy or new challenge contains stale=true parameter (in other case we probably just failed due to invalid username / password)
The method stores challenge values in $challenges static property
- Parameters
-
- Returns
- boolean whether another request should be performed
- Exceptions
-
Definition at line 548 of file Socket.php.
Checks whether another request should be performed with server digest auth
Several conditions should be satisfied for it to return true:
- response status should be 401
- auth credentials should be set in the request object
- response should contain WWW-Authenticate header with digest challenge
- there is either no challenge stored for this URL or new challenge contains stale=true parameter (in other case we probably just failed due to invalid username / password)
The method stores challenge values in $challenges static property
- Parameters
-
- Returns
- boolean whether another request should be performed
- Exceptions
-
Definition at line 483 of file Socket.php.
HTTP_Request2_Adapter_Socket::updateChallenge |
( |
& |
$challenge, |
|
|
|
$headerValue |
|
) |
| |
|
protected |
Parses [Proxy-]Authentication-Info header value and updates challenge
- Parameters
-
array | &$challenge | challenge to update |
string | $headerValue | value of [Proxy-]Authentication-Info header |
- Todo:
- validate server rspauth response
Definition at line 651 of file Socket.php.
HTTP_Request2_Adapter_Socket::updateExpectHeader |
( |
& |
$headers | ) |
|
|
protected |
Adds or removes 'Expect: 100-continue' header from request headers
Also sets the $expect100Continue property. Parsing of existing header is somewhat needed due to its complex structure and due to the requirement in section 8.2.3 of RFC 2616:
A client MUST NOT send an Expect request-header field (section 14.20) with the "100-continue" expectation if it does not intend to send a request body.
- Parameters
-
array | &$headers | Array of headers prepared for the request |
- Exceptions
-
Definition at line 898 of file Socket.php.
HTTP_Request2_Adapter_Socket::writeBody |
( |
| ) |
|
|
protected |
Sends the request body
- Exceptions
-
Definition at line 959 of file Socket.php.
HTTP_Request2_Adapter_Socket::$challenges = array() |
|
staticprotected |
HTTP_Request2_Adapter_Socket::$chunkLength = 0 |
|
protected |
HTTP_Request2_Adapter_Socket::$expect100Continue = false |
|
protected |
HTTP_Request2_Adapter_Socket::$proxyChallenge |
|
protected |
HTTP_Request2_Adapter_Socket::$redirectCountdown = null |
|
protected |
HTTP_Request2_Adapter_Socket::$serverChallenge |
|
protected |
HTTP_Request2_Adapter_Socket::$socket |
|
protected |
HTTP_Request2_Adapter_Socket::$sockets = array() |
|
staticprotected |
const HTTP_Request2_Adapter_Socket::REGEXP_QUOTED_STRING = '"(?>[^"\\\\]+|\\\\.)*"' |
Regular expression for 'quoted-string' rule from RFC 2616
Definition at line 50 of file Socket.php.
const HTTP_Request2_Adapter_Socket::REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+' |
Regular expression for 'token' rule from RFC 2616
Definition at line 45 of file Socket.php.
The documentation for this class was generated from the following file: