## 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 /library/Zend/Http/Client/Abstract.php (line 38)

Direct descendents

Class | Description
--- | ---
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
float $http_version
string $last_request
string $method
array $paramsGet
array $paramsPost
string $raw_post_data
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])
Zend_Http_Response delete ()
Zend_Http_Response get ()
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 487)

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 633)

Send a DELETE request

- access: public
- deprecated: Please use request('DELETE') instead

Zend_Http_Response delete ()
get (line 593)

Send a GET request

- access: public
- deprecated: Please use request('GET') instead

Zend_Http_Response get ()
getHeader (line 311)

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 444)

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 606)

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 620)

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 454)

Send the HTTP request and return a response

- access: public

Zend_Http_Response request ([string $method = null])

- string $method

Redefined in descendants as:

- Zend_Http_Client::request() : Send the HTTP request and return an HTTP response object

resetParameters (line 350)

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:

- Zend_Http_Client::resetParameters() : Clear all GET and POST parameters

setCookie (line 368)

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 392)

Set the encoding type for POST data

- access: public

void setEncType ([string $enctype = self::ENC_URLENCODED])

- string $enctype

setHeader (line 266)

Set or unset 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.

If the value is still null or false after trying to split $name on the ':' character (IE if $name does not contain ':'), the header will be unset.

- 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 423)

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 327)

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 339)

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 408)

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 563)

Open a connection to the remote server

- return: Socket
- access: protected
- abstract:

resource _connect ()

Redefined in descendants as:

- Zend_Http_Client::_connect() : Open a connection to the remote server

_prepare_body (line 555)

Prepare the request body (for POST and PUT requests)

- access: protected
- abstract:

string _prepare_body ()

Redefined in descendants as:

- Zend_Http_Client::_prepare_body() : Prepare the request body (for POST and PUT requests)

_prepare_headers (line 547)

Prepare the request headers

- access: protected
- abstract:

string _prepare_headers ()

Redefined in descendants as:

- Zend_Http_Client::_prepare_headers() : Prepare the request headers

_read (line 581)

Read response from remote server

- access: protected
- abstract:

string _read (resource $socket)

- resource $socket: Socket (returned by _connect())

Redefined in descendants as:

- Zend_Http_Client::_read() : Read response from remote server

_setParameter (line 517)

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 572)

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:

- Zend_Http_Client::_write() : Send request to the remote server

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 Tue, 11 Jul 2006 12:24:12 -0500 by phpDocumentor 1.3.0RC6