Abstract Class Zend_Http_Client_Abstract

Description

Zend_Http_Client_Abstract is the abstract of a Zend HTTP Client class. For the default implementation, use the Zend_Http_Client class.

  • abstract:
  • license: New BSD License
  • copyright: Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)

Located in /Http/Client/Abstract.php (line 38)


	
			
Direct descendents
Class Description
 class Zend_Http_Client Zend_Http_Client is an implemetation of an HTTP client in PHP. The client
Class Constant Summary
 ENC_FORMDATA = 'multipart/form-data'
 ENC_URLENCODED = 'application/x-www-form-urlencoded'
 HTTP_VER_0 = 1.0
 HTTP_VER_1 = 1.1
 METHOD_CONNECT = 'CONNECT'
 METHOD_DELETE = 'DELETE'
 METHOD_GET = 'GET'
 METHOD_HEAD = 'HEAD'
 METHOD_OPTIONS = 'OPTIONS'
 METHOD_POST = 'POST'
 METHOD_PUT = 'PUT'
 METHOD_TRACE = 'TRACE'
Variable Summary
 string $enctype
 array $headers
 string $last_request
 string $method
 array $paramsGet
 array $paramsPost
 int $timeout
 Zend_Uri_Http $uri
 string $user_agent
Method Summary
 static bool validateHeaders ([array $headers = array()])
 Zend_Http_Client_Abstract __construct ([Zend_Uri_Http|string $uri = null], [array $headers = null])
 string|array|null getHeader (unknown_type $key)
 string getLastRequest ()
 string getMethod ()
 Zend_Uri_Http|string getUri ([boolean $as_string = false])
 Zend_Http_Response post ([string $data = null])
 Zend_Http_Response put ([string $data = null])
 Zend_Http_Response request ([string $method = null])
 void resetParameters ()
 void setCookie ( $cookie, [string|null $value = null], Zend_Http_Cookie|string $name)
 void setEncType ([string $enctype = self::ENC_URLENCODED])
 void setHeader (string $name, [string $value = null], [boolean $override = true])
 void setHeaders ([array $headers = array()])
 void setMethod ([string $method = self::METHOD_GET])
 void setParameterGet (string $name, string $value, [boolean $override = true])
 void setParameterPost (string $name, string $value, [boolean $override = true])
 void setRawData (string $data, [string $enctype = null])
 void setTimeout ([int $timeout = 10])
 void setUri (Zend_Uri_Http|string $uri)
 void setUserAgent (string $ua)
 resource _connect ()
 string _prepare_body ()
 string _prepare_headers ()
 string _read (resource $socket)
 void _setParameter (string $type, string $name, string $value, [boolean $override = true])
 void _write (resource $socket, string $request)
Variables
string $enctype = null (line 125)

Request body content type (for POST requests)

  • access: protected
array $headers = array() (line 90)

Associative array of request headers

  • access: protected
float $http_version = self::HTTP_VER_1 (line 97)

Request HTTP version (1.0 or 1.1)

  • access: protected
string $last_request = null (line 139)

The last HTTP request sent by the client, as string

  • access: protected
string $method = self::METHOD_GET (line 104)

HTTP request method

  • access: protected
array $paramsGet = array() (line 111)

Associative array of GET parameters

  • access: protected
array $paramsPost = array() (line 118)

Assiciative array of POST parameters

  • access: protected
string $raw_post_data = null (line 132)

The raw post data to send. Could be set by setRawPostData($data, $enctype).

  • access: protected
int $timeout = 10 (line 83)

Request timeout in seconds

  • access: protected
Zend_Uri_Http $uri (line 76)

Request URI

  • access: protected
string $user_agent = null (line 69)

The user agent string that identifies the HTTP client

  • access: protected
Methods
static validateHeaders (line 475)

Validate an array of headers.

Accepts either an associative array of Header name => Header value format, or a numbered array where all elements are string of the format "Header: value".

  • access: public
  • throws: Zend_Http_Client_Exception
bool validateHeaders ([array $headers = array()])
  • array $headers
Constructor __construct (line 148)

Contructor method. Will create a new HTTP client. Accepts the target URL and optionally and array of headers.

  • access: public
Zend_Http_Client_Abstract __construct ([Zend_Uri_Http|string $uri = null], [array $headers = null])
  • Zend_Uri_Http|string $uri
  • array $headers: Optional request headers to set
delete (line 621)

Send a DELETE request

  • access: public
  • deprecated: Please use request('DELETE') instead
Zend_Http_Response delete ()
get (line 581)

Send a GET request

  • access: public
  • deprecated: Please use request('GET') instead
getHeader (line 299)

Get the value of a specific header

Note that if the header has more than one value, an array will be returned.

  • return: The header value or null if it is not set
  • access: public
string|array|null getHeader (unknown_type $key)
  • unknown_type $key
getLastRequest (line 432)

Get the last HTTP request as string

  • access: public
string getLastRequest ()
getMethod (line 241)

Get the currently-set request method (GET, POST, etc.)

  • access: public
string getMethod ()
getUri (line 184)

Get the URI for the next request

  • access: public
Zend_Uri_Http|string getUri ([boolean $as_string = false])
  • boolean $as_string: If true, will return the URI as a string
post (line 594)

Send a POST request

  • access: public
  • deprecated: Please use request('POST') instead
Zend_Http_Response post ([string $data = null])
  • string $data: Data to send
put (line 608)

Send a PUT request

  • access: public
  • deprecated: Please use request('PUT') instead
Zend_Http_Response put ([string $data = null])
  • string $data: Data to send
request (line 442)

Send the HTTP request and return a response

  • access: public
Zend_Http_Response request ([string $method = null])
  • string $method

Redefined in descendants as:
resetParameters (line 338)

Clear all GET and POST parameters

Should be used to reset the request parameters if the client is used for several concurrent requests.

  • access: public
void resetParameters ()

Redefined in descendants as:
setCookie (line 356)

Set a cookie parameter

  • access: public
void setCookie ( $cookie, [string|null $value = null], Zend_Http_Cookie|string $name)
  • Zend_Http_Cookie|string $name
  • string|null $value: If "cookie" is a string, this is the cookie value.
  • $cookie

Redefined in descendants as:
  • Zend_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.
setEncType (line 380)

Set the encoding type for POST data

  • access: public
void setEncType ([string $enctype = self::ENC_URLENCODED])
  • string $enctype
setHeader (line 261)

Set a request header field

The function validates the header, and sets it. If $override is false, and the header already exists, another value will be added to the same header. if $value is null, name is considered a string of the format "Header: value", which will be split to get the header name and value.

  • access: public
void setHeader (string $name, [string $value = null], [boolean $override = true])
  • string $name: Header name or entire header string
  • string $value: Header value or null
  • boolean $override: Whether to rewrite the header if it is already set, or add another similar header
setHeaders (line 411)

Set the next request's headers.

Receives an array of headers, which can be eithr an associative array of the form "Header" => "value" (eg. "Host" => "www.example.com") or a numbered array of string, each of the format "Header: value".

  • access: public
void setHeaders ([array $headers = array()])
  • array $headers
setMethod (line 221)

Set the next request's method

Validated the passed method and sets it. If we have files set for POST requests, and the new method is not POST, the files are silently dropped.

  • access: public
void setMethod ([string $method = self::METHOD_GET])
  • string $method
setParameterGet (line 315)

Set a GET parameter for the request. Wrapper around _setParameter

  • access: public
void setParameterGet (string $name, string $value, [boolean $override = true])
  • string $name
  • string $value
  • boolean $override: Whether to overwrite the parameter's value
setParameterPost (line 327)

Set a POST parameter for the request. Wrapper around _setParameter

  • access: public
void setParameterPost (string $name, string $value, [boolean $override = true])
  • string $name
  • string $value
  • boolean $override: Whether to overwrite the parameter's value
setRawData (line 396)

Set the raw (already encoded) POST data.

This function is here for two reasons:

  1. For advanced user who would like to set their own data, already encoded
  2. For backwards compatibilty: If someone uses the old post($data) method. this method will be used to set the encoded data.

  • access: public
void setRawData (string $data, [string $enctype = null])
  • string $data
  • string $enctype
setTimeout (line 207)

Set the client's connection timeout in seconds, 0 for none

  • access: public
void setTimeout ([int $timeout = 10])
  • int $timeout
setUri (line 160)

Set the URI for the next request

  • access: public
void setUri (Zend_Uri_Http|string $uri)
  • Zend_Uri_Http|string $uri
setUserAgent (line 198)

Set the user agent identification string

  • access: public
void setUserAgent (string $ua)
  • string $ua
_connect (line 551)

Open a connection to the remote server

  • return: Socket
  • access: protected
  • abstract:
resource _connect ()

Redefined in descendants as:
_prepare_body (line 543)

Prepare the request body (for POST and PUT requests)

  • access: protected
  • abstract:
string _prepare_body ()

Redefined in descendants as:
_prepare_headers (line 535)

Prepare the request headers

  • access: protected
  • abstract:
string _prepare_headers ()

Redefined in descendants as:
_read (line 569)

Read response from remote server

  • access: protected
  • abstract:
string _read (resource $socket)
  • resource $socket: Socket (returned by _connect())

Redefined in descendants as:
_setParameter (line 505)

Set a GET or POST parameter - used by SetParameterGet and SetParameterPost

  • access: protected
void _setParameter (string $type, string $name, string $value, [boolean $override = true])
  • string $type: GET or POST
  • string $name
  • string $value
  • boolean $override: Whether to replace old value, or add it as an array of values
_write (line 560)

Send request to the remote server

  • access: protected
  • abstract:
void _write (resource $socket, string $request)
  • resource $socket: Socket (returned by _connect())
  • string $request: Request to send

Redefined in descendants as:
Class Constants
ENC_FORMDATA = 'multipart/form-data' (line 62)
ENC_URLENCODED = 'application/x-www-form-urlencoded' (line 61)

POST data encoding methods

HTTP_VER_0 = 1.0 (line 44)
HTTP_VER_1 = 1.1 (line 43)

HTTP protocol versions

METHOD_CONNECT = 'CONNECT' (line 56)
METHOD_DELETE = 'DELETE' (line 53)
METHOD_GET = 'GET' (line 49)

HTTP request methods

METHOD_HEAD = 'HEAD' (line 52)
METHOD_OPTIONS = 'OPTIONS' (line 55)
METHOD_POST = 'POST' (line 50)
METHOD_PUT = 'PUT' (line 51)
METHOD_TRACE = 'TRACE' (line 54)

Documentation generated on Fri, 30 Jun 2006 11:29:39 -0500 by phpDocumentor 1.3.0RC6