\Zend_Http_Client
Zend_Http_Client is an implemetation of an HTTP client in PHP. The client supports basic features like sending different HTTP requests and handling redirections, as well as more advanced features like proxy settings, HTTP authentication and cookie persistance (using a Zend_Http_CookieJar object)
- Copyright: Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
- License: http://framework.zend.com/license/new-bsd New BSD License
Synopsis
class Zend_Http_Client
{
- // constants
- const GET = 'GET';
- const POST = 'POST';
- const PUT = 'PUT';
- const HEAD = 'HEAD';
- const DELETE = 'DELETE';
- const TRACE = 'TRACE';
- const OPTIONS = 'OPTIONS';
- const CONNECT = 'CONNECT';
- const AUTH_BASIC = 'basic';
- const HTTP_1 = '1.1';
- const HTTP_0 = '1.0';
- const CONTENT_TYPE = 'Content-Type';
- const CONTENT_LENGTH = 'Content-Length';
- const ENC_URLENCODED = 'application/x-www-form-urlencoded';
- const ENC_FORMDATA = 'multipart/form-data';
- // members
- protected array $config = ;
- protected Zend_Http_Client_Adapter_Interface $adapter = NULL;
- protected Zend_Uri_Http $uri;
- protected array $headers = ;
- protected string $method = self::GET;
- protected array $paramsGet = ;
- protected array $paramsPost = ;
- protected $enctype = NULL;
- protected $raw_post_data = NULL;
- protected array|null $auth;
- protected array $files = ;
- protected Zend_Http_CookieJar $cookiejar = NULL;
- protected $last_request = NULL;
- protected Zend_Http_Response $last_response = NULL;
- protected integer $redirectCounter = 0;
- protected static $_fileInfoDb = NULL;
- // methods
- public void __construct()
- public Zend_Http_Client setUri()
- public Zend_Uri_Http|string getUri()
- public Zend_Http_Client setConfig()
- public Zend_Http_Client setMethod()
- public Zend_Http_Client setHeaders()
- public string|array|null getHeader()
- public Zend_Http_Client setParameterGet()
- public Zend_Http_Client setParameterPost()
- protected null _setParameter()
- public int getRedirectionsCount()
- public Zend_Http_Client setAuth()
- public Zend_Http_Client setCookieJar()
- public Zend_Http_CookieJar|null getCookieJar()
- public Zend_Http_Client setCookie()
- public Zend_Http_Client setFileUpload()
- public Zend_Http_Client setEncType()
- public Zend_Http_Client setRawData()
- public Zend_Http_Client resetParameters()
- public string getLastRequest()
- public Zend_Http_Response getLastResponse()
- public null setAdapter()
- public Zend_Http_Response request()
- protected array _prepareHeaders()
- protected string _prepareBody()
- protected array _getParametersRecursive()
- protected string _detectFileMimeType()
- public static string encodeFormData()
- public static string encodeAuthHeader()
Tasks
Line | Task |
---|---|
61+ | Implement proxy settings |
Constants
Name | Value |
---|---|
GET | 'GET' |
POST | 'POST' |
PUT | 'PUT' |
HEAD | 'HEAD' |
DELETE | 'DELETE' |
TRACE | 'TRACE' |
OPTIONS | 'OPTIONS' |
CONNECT | 'CONNECT' |
AUTH_BASIC | 'basic' |
HTTP_1 | '1.1' |
HTTP_0 | '1.0' |
CONTENT_TYPE | 'Content-Type' |
CONTENT_LENGTH | 'Content-Length' |
ENC_URLENCODED | 'application/x-www-form-urlencoded' |
ENC_FORMDATA | 'multipart/form-data' |
Members
protected
- $_fileInfoDb
—
resource
Fileinfo magic database resource - $adapter
—
Zend_Http_Client_Adapter_Interface
The adapter used to preform the actual connection to the server - $auth
—
array|null
HTTP Authentication settings - $config
—
array
Configuration array, set using the constructor or using ::setConfig() - $enctype
—
string
Request body content type (for POST requests) - $files
—
array
File upload arrays (used in POST requests) - $headers
—
array
Associative array of request headers - $last_request
—
string
The last HTTP request sent by the client, as string - $last_response
—
Zend_Http_Response
The last HTTP response received by the client - $method
—
string
HTTP request method - $paramsGet
—
array
Associative array of GET parameters - $paramsPost
—
array
Assiciative array of POST parameters - $raw_post_data
—
string
The raw post data to send. Could be set by setRawData($data, $enctype). - $redirectCounter
—
int
Redirection counter - $uri
—
Zend_Uri_Http
Request URI
Methods
protected
- _detectFileMimeType() — Attempt to detect the MIME type of a file using available extensions
- _getParametersRecursive() — Helper method that gets a possibly multi-level parameters array (get or post) and flattens it.
- _prepareBody() — Prepare the request body (for POST and PUT requests)
- _prepareHeaders() — Prepare the request headers
- _setParameter() — Set a GET or POST parameter - used by SetParameterGet and SetParameterPost
public
- __construct() — Contructor method. Will create a new HTTP client. Accepts the target URL and optionally configuration array.
- encodeAuthHeader() — Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
- encodeFormData() — Encode data to a multipart/form-data part suitable for a POST request.
- getCookieJar() — Return the current cookie jar or null if none.
- getHeader() — Get the value of a specific header
- getLastRequest() — Get the last HTTP request as string
- getLastResponse() — Get the last HTTP response received by this client
- getRedirectionsCount() — Get the number of redirections done on the last request
- getUri() — Get the URI for the next request
- request() — Send the HTTP request and return an HTTP response object
- resetParameters() — Clear all GET and POST parameters
- setAdapter() — Load the connection adapter
- setAuth() — Set HTTP authentication parameters
- setConfig() — Set configuration parameters for this HTTP client
- setCookie() — Add a cookie to the request. If the client has no Cookie Jar, the cookies will be added directly to the headers array as "Cookie" headers.
- setCookieJar() — Set the HTTP client's cookie jar.
- setEncType() — Set the encoding type for POST data
- setFileUpload() — Set a file to upload (using a POST request)
- setHeaders() — Set one or more request headers
- setMethod() — Set the next request's method
- setParameterGet() — Set a GET parameter for the request. Wrapper around _setParameter
- setParameterPost() — Set a POST parameter for the request. Wrapper around _setParameter
- setRawData() — Set the raw (already encoded) POST data.
- setUri() — Set the URI for the next request