Handles all linear and parallel HTTP requests using cURL.
2008.11.03
2006-2008 LifeNexus Digital, Inc., and contributors.
| Simplified BSD License | http://opensource.org/licenses/bsd-license.php |
| Tarzan | http://tarzan-aws.com |
The default class to use for Utilities (defaults to TarzanUtilities).
The default class to use for HTTP Requests (defaults to TarzanHTTPRequest).
The default class to use for HTTP Responses (defaults to TarzanHTTPResponse).
public function __construct( $url, $proxy = null, $helpers = null )
The constructor
public
| url | string (Required) The URL to request or service endpoint to query. |
| proxy | string (Optional) The faux-url to use for proxy settings. Takes the following format: proxy://user:pass@hostname:port |
| helpers | array (Optional) An associative array of classnames to use for utilities, request, and response functionality. Gets passed in automatically by the calling class. |
void
| Example Usage | http://tarzan-aws.com |
public function setCredentials( $user, $pass )
Sets the credentials to use for authentication.
public
| user | string (Required) The username to authenticate with. |
| pass | string (Required) The password to authenticate with. |
void
| Example Usage | http://tarzan-aws.com |
public function addHeader( $key, $value )
Adds a custom HTTP header to the cURL request.
public
| key | string (Required) The custom HTTP header to set. |
| value | mixed (Required) The value to assign to the custom HTTP header. |
void
| Example Usage | http://tarzan-aws.com |
public function removeHeader( $key )
Removes an HTTP header from the cURL request.
public
| key | string (Required) The custom HTTP header to set. |
void
| Example Usage | http://tarzan-aws.com |
public function setMethod( $method )
Set the method type for the request.
public
| method | string (Required) One of the following constants: HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_HEAD, HTTP_DELETE. |
void
| Example Usage | http://tarzan-aws.com |
public function setBody( $body )
Set the body to send in the request.
public
| body | string (Required) The textual content to send along in the body of the request. |
void
| Example Usage | http://tarzan-aws.com |
public function processResponse( $curl_handle = null, $response = null )
Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the data stored in the curl_handle and response properties unless replacement data is passed in via parameters.
public
| curl_handle | string (Optional) The reference to the already executed cURL request. |
| response | string (Optional) The actual response content itself that needs to be parsed. |
TarzanHTTPResponse object
public function sendRequest()
Sends the request, calling necessary utility functions to update built-in properties.
public
string The resulting unparsed data from the request.
| Related | sendMultiRequest() |
| Example Usage | http://tarzan-aws.com |
public function sendMultiRequest( $handles )
Sends the request using curl_multi_exec(), enabling parallel requests.
public
| handles | array (Required) An indexed array of cURL handles to process simultaneously. |
array Post-processed cURL responses.
| Related | sendRequest() |
| Example Usage | http://tarzan-aws.com |
public function getResponseHeader( $header = null )
Get the HTTP response headers from the request.
public
| header | string (Optional) A specific header value to return. Defaults to all headers. |
string | array All or selected header values.
| Related | getResponseBody(), getResponseCode() |
| Example Usage | http://tarzan-aws.com |
public function getResponseBody()
Get the HTTP response body from the request.
public
string The response body.
| Related | getResponseHeader(), getResponseCode() |
| Example Usage | http://tarzan-aws.com |
public function getResponseCode()
Get the HTTP response code from the request.
public
string The HTTP response code.
| Related | getResponseHeader(), getResponseBody() |
| Example Usage | http://tarzan-aws.com |