Gdata/HttpClient.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Gdata  
Subpackage
Gdata  
Version
$Id: HttpClient.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Gdata_HttpClient

Package: Zend\Gdata\Gdata
Gdata Http Client object.

Class to extend the generic Zend Http Client with the ability to perform secure AuthSub requests

Parent(s)
\Zend_Http_Client
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  GET = 'GET'
inherited
HTTP request methods
Inherited from: \Zend_Http_Client::GET
Inherited_from
\Zend_Http_Client::GET  
>VConstant  POST = 'POST'
inheritedInherited from: \Zend_Http_Client::POST
Inherited_from
\Zend_Http_Client::POST  
>VConstant  PUT = 'PUT'
inheritedInherited from: \Zend_Http_Client::PUT
Inherited_from
\Zend_Http_Client::PUT  
>VConstant  HEAD = 'HEAD'
inheritedInherited from: \Zend_Http_Client::HEAD
Inherited_from
\Zend_Http_Client::HEAD  
>VConstant  DELETE = 'DELETE'
inheritedInherited from: \Zend_Http_Client::DELETE
Inherited_from
\Zend_Http_Client::DELETE  
>VConstant  TRACE = 'TRACE'
inheritedInherited from: \Zend_Http_Client::TRACE
Inherited_from
\Zend_Http_Client::TRACE  
>VConstant  OPTIONS = 'OPTIONS'
inheritedInherited from: \Zend_Http_Client::OPTIONS
Inherited_from
\Zend_Http_Client::OPTIONS  
>VConstant  CONNECT = 'CONNECT'
inheritedInherited from: \Zend_Http_Client::CONNECT
Inherited_from
\Zend_Http_Client::CONNECT  
>VConstant  MERGE = 'MERGE'
inheritedInherited from: \Zend_Http_Client::MERGE
Inherited_from
\Zend_Http_Client::MERGE  
>VConstant  AUTH_BASIC = 'basic'
inherited
Supported HTTP Authentication methods
Inherited from: \Zend_Http_Client::AUTH_BASIC
>VConstant  HTTP_1 = '1.1'
inherited
HTTP protocol versions
Inherited from: \Zend_Http_Client::HTTP_1
Inherited_from
\Zend_Http_Client::HTTP_1  
>VConstant  HTTP_0 = '1.0'
inheritedInherited from: \Zend_Http_Client::HTTP_0
Inherited_from
\Zend_Http_Client::HTTP_0  
>VConstant  CONTENT_TYPE = 'Content-Type'
inherited
Content attributes
Inherited from: \Zend_Http_Client::CONTENT_TYPE
>VConstant  CONTENT_LENGTH = 'Content-Length'
inheritedInherited from: \Zend_Http_Client::CONTENT_LENGTH
>VConstant  ENC_URLENCODED = 'application/x-www-form-urlencoded'
inherited
POST data encoding methods
Inherited from: \Zend_Http_Client::ENC_URLENCODED
>VConstant  ENC_FORMDATA = 'multipart/form-data'
inheritedInherited from: \Zend_Http_Client::ENC_FORMDATA
>VConstant  VTYPE_SCALAR = 'SCALAR'
inherited
Value types for Body key/value pairs
Inherited from: \Zend_Http_Client::VTYPE_SCALAR
>VConstant  VTYPE_FILE = 'FILE'
inheritedInherited from: \Zend_Http_Client::VTYPE_FILE

Properties

>VPropertyprivateresource $_authSubPrivateKeyId = null
OpenSSL private key resource id This key is used for AuthSub authentication.

If this value is set, it is assuemd that secure AuthSub is desired.

Default valuenullDetails
Type
resource
>VPropertyprivatestring $_authSubToken = null
Token for AuthSub authentication.

If this token is set, AuthSub authentication is used.

Default valuenullDetails
Type
string
>VPropertyprivatestring $_clientLoginKey = null
Token for ClientLogin authentication.

If this token is set, and the AuthSub key is not set, ClientLogin authentication is used

Default valuenullDetails
Type
string
>VPropertyprivatestring $_clientLoginToken = null
Token for ClientLogin authentication.

If only this token is set, ClientLogin authentication is used.

Default valuenullDetails
Type
string
>VPropertyprotectedresource $_fileInfoDb = null
staticinherited
Fileinfo magic database resource
Inherited from: \Zend_Http_Client::$$_fileInfoDb

This variable is populated the first time _detectFileMimeType is called and is then reused on every call to this method

Default valuenullDetails
Type
resource
Inherited_from
\Zend_Http_Client::$$_fileInfoDb  
>VPropertyprotectedboolean $_queryBracketsEscaped = true
inherited
Status if the http_build_query function escapes brackets
Inherited from: \Zend_Http_Client::$$_queryBracketsEscaped
Default valuetrueDetails
Type
boolean
Inherited_from
\Zend_Http_Client::$$_queryBracketsEscaped  
>VPropertyprotectedbool $_streamingRequest = null
True if this request is being made with data supplied by a stream object instead of a raw encoded string.
Default valuenullDetails
Type
bool
>VPropertyprotectedboolean $_unmaskStatus = false
inherited
Status for unmasking GET array params
Inherited from: \Zend_Http_Client::$$_unmaskStatus
Default valuefalseDetails
Type
boolean
Inherited_from
\Zend_Http_Client::$$_unmaskStatus  
>VPropertyprotected\Zend_Http_Client_Adapter_Interface $adapter = null
inherited
The adapter used to perform the actual connection to the server
Inherited from: \Zend_Http_Client::$$adapter
Default valuenullDetails
Type
\Zend_Http_Client_Adapter_Interface
Inherited_from
\Zend_Http_Client::$$adapter  
>VPropertyprotectedarray|null $auth
inherited
HTTP Authentication settings
Inherited from: \Zend_Http_Client::$$auth

Expected to be an associative array with this structure: $this->auth = array('user' => 'username', 'password' => 'password', 'type' => 'basic') Where 'type' should be one of the supported authentication types (see the AUTH_* constants), for example 'basic' or 'digest'.

If null, no authentication will be used.

Details
Type
array | null
Inherited_from
\Zend_Http_Client::$$auth  
>VPropertyprotectedarray $body_field_order = array()
inherited
Ordered list of keys from key/value pair data to include in body
Inherited from: \Zend_Http_Client::$$body_field_order

An associative array, where each element is of the format: '' => VTYPE_SCALAR | VTYPE_FILE

Default valuearray()Details
Type
array
Inherited_from
\Zend_Http_Client::$$body_field_order  
>VPropertyprotectedarray $config = array('maxredirects' => 5, 'strictredirects' => false, 'useragent' => 'Zend_Http_Client', 'timeout' => 10, 'adapter' => 'Zend_Http_Client_Adapter_Socket', 'httpversion' => self::HTTP_1, 'keepalive' => false, 'storeresponse' => true, 'strict' => true, 'output_stream' => false, 'encodecookies' => true, 'rfc3986_strict' => false)
inherited
Configuration array, set using the constructor or using ::setConfig()
Inherited from: \Zend_Http_Client::$$config
Default valuearray('maxredirects' => 5, 'strictredirects' => false, 'useragent' => 'Zend_Http_Client', 'timeout' => 10, 'adapter' => 'Zend_Http_Client_Adapter_Socket', 'httpversion' => self::HTTP_1, 'keepalive' => false, 'storeresponse' => true, 'strict' => true, 'output_stream' => false, 'encodecookies' => true, 'rfc3986_strict' => false)Details
Type
array
Inherited_from
\Zend_Http_Client::$$config  
>VPropertyprotected\Zend_Http_CookieJar $cookiejar = null
inherited
The client's cookie jar
Inherited from: \Zend_Http_Client::$$cookiejar
Default valuenullDetails
Type
\Zend_Http_CookieJar
Inherited_from
\Zend_Http_Client::$$cookiejar  
>VPropertyprotectedstring $enctype = null
inherited
Request body content type (for POST requests)
Inherited from: \Zend_Http_Client::$$enctype
Default valuenullDetails
Type
string
Inherited_from
\Zend_Http_Client::$$enctype  
>VPropertyprotectedarray $files = array()
inherited
File upload arrays (used in POST requests)
Inherited from: \Zend_Http_Client::$$files

An associative array, where each element is of the format: 'name' => array('filename.txt', 'text/plain', 'This is the actual file contents')

Default valuearray()Details
Type
array
Inherited_from
\Zend_Http_Client::$$files  
>VPropertyprotectedarray $headers = array()
inherited
Associative array of request headers
Inherited from: \Zend_Http_Client::$$headers
Default valuearray()Details
Type
array
Inherited_from
\Zend_Http_Client::$$headers  
>VPropertyprotectedstring $last_request = null
inherited
The last HTTP request sent by the client, as string
Inherited from: \Zend_Http_Client::$$last_request
Default valuenullDetails
Type
string
Inherited_from
\Zend_Http_Client::$$last_request  
>VPropertyprotected\Zend_Http_Response $last_response = null
inherited
The last HTTP response received by the client
Inherited from: \Zend_Http_Client::$$last_response
Default valuenullDetails
Type
\Zend_Http_Response
Inherited_from
\Zend_Http_Client::$$last_response  
>VPropertyprotectedstring $method = self::GET
inherited
HTTP request method
Inherited from: \Zend_Http_Client::$$method
Default valueself::GETDetails
Type
string
Inherited_from
\Zend_Http_Client::$$method  
>VPropertyprotectedarray $paramsGet = array()
inherited
Associative array of GET parameters
Inherited from: \Zend_Http_Client::$$paramsGet
Default valuearray()Details
Type
array
Inherited_from
\Zend_Http_Client::$$paramsGet  
>VPropertyprotectedarray $paramsPost = array()
inherited
Associative array of POST parameters
Inherited from: \Zend_Http_Client::$$paramsPost
Default valuearray()Details
Type
array
Inherited_from
\Zend_Http_Client::$$paramsPost  
>VPropertyprotectedstring $raw_post_data = null
inherited
The raw post data to send.
Inherited from: \Zend_Http_Client::$$raw_post_data

Could be set by setRawData($data, $enctype).

Default valuenullDetails
Type
string
Inherited_from
\Zend_Http_Client::$$raw_post_data  
>VPropertyprotectedint $redirectCounter = 0
inherited
Redirection counter
Inherited from: \Zend_Http_Client::$$redirectCounter
Default value0Details
Type
int
Inherited_from
\Zend_Http_Client::$$redirectCounter  
>VPropertyprotected\Zend_Uri_Http $uri = null
inherited
Request URI
Inherited from: \Zend_Http_Client::$$uri
Default valuenullDetails
Type
\Zend_Uri_Http
Inherited_from
\Zend_Http_Client::$$uri  

Methods

methodpublic__construct(\Zend_Uri_Http | string $uri = null, array $config = null) : void
inherited

Constructor method.

Inherited from: \Zend_Http_Client::__construct()

Will create a new HTTP client. Accepts the target URL and optionally configuration array.

Parameters
NameTypeDescription
$uri\Zend_Uri_Http | string
$configarray

Configuration key-value pairs.

methodprotected_detectFileMimeType(string $file) : string
inherited

Attempt to detect the MIME type of a file using available extensions

Inherited from: \Zend_Http_Client::_detectFileMimeType()

This method will try to detect the MIME type of a file. If the fileinfo extension is available, it will be used. If not, the mime_magic extension which is deprected but is still available in many PHP setups will be tried.

If neither extension is available, the default application/octet-stream MIME type will be returned

Parameters
NameTypeDescription
$filestring

File path

Returns
TypeDescription
stringMIME type
methodprotected_flattenParametersArray(array $parray, string $prefix = null) : array
staticinherited

Convert an array of parameters into a flat array of (key, value) pairs

Inherited from: \Zend_Http_Client::_flattenParametersArray()

Will flatten a potentially multi-dimentional array of parameters (such as POST parameters) into a flat array of (key, value) paris. In case of multi-dimentional arrays, square brackets ([]) will be added to the key to indicate an array.

Parameters
NameTypeDescription
$parrayarray
$prefixstring
Returns
TypeDescription
array
Details
Since
1.9  
methodprotected_getParametersRecursive(array $parray, bool $urlencode = false) : array
inherited

Helper method that gets a possibly multi-level parameters array (get or post) and flattens it.

Inherited from: \Zend_Http_Client::_getParametersRecursive()

The method returns an array of (key, value) pairs (because keys are not necessarily unique. If one of the parameters in as array, it will also add a [] suffix to the key.

This method is deprecated since Zend Framework 1.9 in favour of self::_flattenParametersArray() and will be dropped in 2.0

Parameters
NameTypeDescription
$parrayarray

The parameters array

$urlencodebool

Whether to urlencode the name and value

Returns
TypeDescription
array
methodprotected_openTempStream() : resource
inherited

Create temporary stream

Inherited from: \Zend_Http_Client::_openTempStream()
Returns
TypeDescription
resource
methodprotected_prepareBody() : string

Prepare the request body (for POST and PUT requests)

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodprotected_prepareHeaders() : array
inherited

Prepare the request headers

Inherited from: \Zend_Http_Client::_prepareHeaders()
Returns
TypeDescription
array
methodprotected_setParameter(string $type, string $name, string $value) : null
inherited

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

Inherited from: \Zend_Http_Client::_setParameter()
Parameters
NameTypeDescription
$typestring

GET or POST

$namestring
$valuestring
Returns
TypeDescription
null
methodpublicencodeAuthHeader(string $user, string $password, string $type = self::AUTH_BASIC) : string
staticinherited

Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.

Inherited from: \Zend_Http_Client::encodeAuthHeader()
Parameters
NameTypeDescription
$userstring
$passwordstring
$typestring
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Http_Client_Exception
Details
See
\http://www.faqs.org/rfcs/rfc2617.html  
methodpublicencodeFormData(string $boundary, string $name, mixed $value, string $filename = null, array $headers = array()) : string
staticinherited

Encode data to a multipart/form-data part suitable for a POST request.

Inherited from: \Zend_Http_Client::encodeFormData()
Parameters
NameTypeDescription
$boundarystring
$namestring
$valuemixed
$filenamestring
$headersarray

Associative array of optional headers @example ("Content-Transfer-Encoding" => "binary")

Returns
TypeDescription
string
methodpublicfilterHttpRequest(string $method, string $url, array $headers = array(), string $body = null, string $contentType = null) : array

Filters the HTTP requests being sent to add the Authorization header.

If both AuthSub and ClientLogin tokens are set, AuthSub takes precedence. If an AuthSub key is set, then secure AuthSub authentication is used, and the request is signed. Requests must be signed only with the private key corresponding to the public key registered with Google. If an AuthSub key is set, but openssl support is not enabled in the PHP installation, an exception is thrown.

Parameters
NameTypeDescription
$methodstring

The HTTP method

$urlstring

The URL

$headersarray

An associate array of headers to be sent with the request or null

$bodystring

The body of the request or null

$contentTypestring

The MIME content type of the body or null

Returns
TypeDescription
arrayThe processed values in an associative array, using the same names as the params
Throws
ExceptionDescription
\Zend_Gdata_App_Exceptionif there was a signing failure
methodpublicfilterHttpResponse(\Zend_Http_Response $response) : \Zend_Http_Response

Method for filtering the HTTP response, though no filtering is currently done.

Parameters
NameTypeDescription
$response\Zend_Http_Response

The response object to filter

Returns
TypeDescription
\Zend_Http_ResponseThe filterd response object
methodpublicgetAdapter() : \Zend_Http_Client_Adapter_Interface | string

Return the current connection adapter

Returns
TypeDescription
\Zend_Http_Client_Adapter_Interface | string$adapter
methodpublicgetAuthSubPrivateKeyId() : string

Gets the openssl private key id

Returns
TypeDescription
stringThe private key
methodpublicgetAuthSubToken() : string

Gets the AuthSub token used for authentication

Returns
TypeDescription
stringThe token
methodpublicgetClientLoginToken() : string

Gets the ClientLogin token used for authentication

Returns
TypeDescription
stringThe token
methodpublicgetCookieJar() : \Zend_Http_CookieJar | null
inherited

Return the current cookie jar or null if none.

Inherited from: \Zend_Http_Client::getCookieJar()
Returns
TypeDescription
\Zend_Http_CookieJar | null
methodpublicgetHeader(string $key) : string | array | null
inherited

Get the value of a specific header

Inherited from: \Zend_Http_Client::getHeader()

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

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
string | array | nullThe header value or null if it is not set
methodpublicgetLastRequest() : string
inherited

Get the last HTTP request as string

Inherited from: \Zend_Http_Client::getLastRequest()
Returns
TypeDescription
string
methodpublicgetLastResponse() : \Zend_Http_Response
inherited

Get the last HTTP response received by this client

Inherited from: \Zend_Http_Client::getLastResponse()

If $config['storeresponse'] is set to false, or no response was stored yet, will return null

Returns
TypeDescription
\Zend_Http_Responseor null if none
methodpublicgetRedirectionsCount() : int
inherited

Get the number of redirections done on the last request

Inherited from: \Zend_Http_Client::getRedirectionsCount()
Returns
TypeDescription
int
methodpublicgetStream() : boolean | string
inherited

Get status of streaming for received data

Inherited from: \Zend_Http_Client::getStream()
Returns
TypeDescription
boolean | string
methodpublicgetStreamingRequest() : boolean

Check whether the client is set to perform streaming requests.

Returns
TypeDescription
booleanTrue if yes, false otherwise.
methodpublicgetUnmaskStatus() : boolean
inherited

Returns the currently configured unmask status

Inherited from: \Zend_Http_Client::getUnmaskStatus()
Returns
TypeDescription
boolean
methodpublicgetUri(boolean $as_string = false) : \Zend_Uri_Http | string
inherited

Get the URI for the next request

Inherited from: \Zend_Http_Client::getUri()
Parameters
NameTypeDescription
$as_stringboolean

If true, will return the URI as a string

Returns
TypeDescription
\Zend_Uri_Http | string
methodpublicrequest(string $method = null) : \Zend_Http_Response
inherited

Send the HTTP request and return an HTTP response object

Inherited from: \Zend_Http_Client::request()
Parameters
NameTypeDescription
$methodstring
Returns
TypeDescription
\Zend_Http_Response
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicresetParameters(bool $clearAll = false) : \Zend_Http_Client

Clear all custom parameters we set.

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

clearAll parameter controls if we clean just parameters or also headers and last_*

Parameters
NameTypeDescription
$clearAllbool

Should all data be cleared?

Returns
TypeDescription
\Zend_Http_Client
methodpublicsetAdapter(\Zend_Http_Client_Adapter_Interface $adapter) : void

Load the connection adapter

While this method is not called more than one for a client, it is seperated from ->request() to preserve logic and readability

Parameters
NameTypeDescription
$adapter\Zend_Http_Client_Adapter_Interface
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicsetAuth(string | false $user, string $password = '', string $type = self::AUTH_BASIC) : \Zend_Http_Client
inherited

Set HTTP authentication parameters

Inherited from: \Zend_Http_Client::setAuth()

$type should be one of the supported types - see the self::AUTH_* constants.

To enable authentication:

$this->setAuth('shahar', 'secret', Zend_Http_Client::AUTH_BASIC);

To disable authentication:

$this->setAuth(false);
Parameters
NameTypeDescription
$userstring | false

User name or false disable authentication

$passwordstring

Password

$typestring

Authentication type

Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
Details
See
\http://www.faqs.org/rfcs/rfc2617.html  
methodpublicsetAuthSubPrivateKey(string $key, string $passphrase = null) : \Zend_Gdata_HttpClient

Sets the PEM formatted private key to be used for secure AuthSub auth.

In order to call this method, openssl must be enabled in your PHP installation. Otherwise, a Zend_Gdata_App_InvalidArgumentException will be thrown.

Parameters
NameTypeDescription
$keystring

The private key

$passphrasestring

The optional private key passphrase

Returns
TypeDescription
\Zend_Gdata_HttpClientProvides a fluent interface
Throws
ExceptionDescription
\Zend_Gdata_App_InvalidArgumentException
methodpublicsetAuthSubPrivateKeyFile(string $file, string $passphrase = null, bool $useIncludePath = false) : void

Sets the PEM formatted private key, as read from a file.

This method reads the file and then calls setAuthSubPrivateKey() with the file contents.

Parameters
NameTypeDescription
$filestring

The location of the file containing the PEM key

$passphrasestring

The optional private key passphrase

$useIncludePathbool

Whether to search the include_path for the file

methodpublicsetAuthSubToken(string $token) : \Zend_Gdata_HttpClient

Sets the AuthSub token used for authentication

Parameters
NameTypeDescription
$tokenstring

The token

Returns
TypeDescription
\Zend_Gdata_HttpClientProvides a fluent interface
methodpublicsetClientLoginToken(string $token) : \Zend_Gdata_HttpClient

Sets the ClientLogin token used for authentication

Parameters
NameTypeDescription
$tokenstring

The token

Returns
TypeDescription
\Zend_Gdata_HttpClientProvides a fluent interface
methodpublicsetConfig(\Zend_Config $config = array()) : \Zend_Http_Client
inherited

Set configuration parameters for this HTTP client

Inherited from: \Zend_Http_Client::setConfig()
Parameters
NameTypeDescription
$config\Zend_Config

| array $config

Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicsetCookie(\Zend_Http_Cookie | string $cookie, string | null $value = null) : \Zend_Http_Client
inherited

Add a cookie to the request.

Inherited from: \Zend_Http_Client::setCookie()

If the client has no Cookie Jar, the cookies will be added directly to the headers array as "Cookie" headers.

Parameters
NameTypeDescription
$cookie\Zend_Http_Cookie | string
$valuestring | null

If "cookie" is a string, this is the cookie value.

Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicsetCookieJar(\Zend_Http_CookieJar | boolean $cookiejar = true) : \Zend_Http_Client
inherited

Set the HTTP client's cookie jar.

Inherited from: \Zend_Http_Client::setCookieJar()

A cookie jar is an object that holds and maintains cookies across HTTP requests and responses.

Parameters
NameTypeDescription
$cookiejar\Zend_Http_CookieJar | boolean

Existing cookiejar object, true to create a new one, false to disable

Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicsetEncType(string $enctype = self::ENC_URLENCODED) : \Zend_Http_Client
inherited

Set the encoding type for POST data

Inherited from: \Zend_Http_Client::setEncType()
Parameters
NameTypeDescription
$enctypestring
Returns
TypeDescription
\Zend_Http_Client
methodpublicsetFileUpload(string $filename, string $formname, string $data = null, string $ctype = null) : \Zend_Http_Client
inherited

Set a file to upload (using a POST request)

Inherited from: \Zend_Http_Client::setFileUpload()

Can be used in two ways:

  1. $data is null (default): $filename is treated as the name if a local file which will be read and sent. Will try to guess the content type using mime_content_type().
  2. $data is set - $filename is sent as the file name, but $data is sent as the file contents and no file is read from the file system. In this case, you need to manually set the Content-Type ($ctype) or it will default to application/octet-stream.
Parameters
NameTypeDescription
$filenamestring

Name of file to upload, or name to save as

$formnamestring

Name of form element to send as

$datastring

Data to send (if null, $filename is read and sent)

$ctypestring

Content type to use (if $data is set and $ctype is null, will be application/octet-stream)

Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicsetHeaders(string | array $name, mixed $value = null) : \Zend_Http_Client
inherited

Set one or more request headers

Inherited from: \Zend_Http_Client::setHeaders()

This function can be used in several ways to set the client's request headers: 1. By providing two parameters: $name as the header to set (e.g. 'Host') and $value as it's value (e.g. 'www.example.com'). 2. By providing a single header string as the only parameter e.g. 'Host: www.example.com' 3. By providing an array of headers as the first parameter e.g. array('host' => 'www.example.com', 'x-foo: bar'). In This case the function will call itself recursively for each array item.

Parameters
NameTypeDescription
$namestring | array

Header name, full header string ('Header: value') or an array of headers

$valuemixed

Header value or null

Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicsetMethod(string $method = self::GET) : \Zend_Http_Client
inherited

Set the next request's method

Inherited from: \Zend_Http_Client::setMethod()

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.

Parameters
NameTypeDescription
$methodstring
Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
methodpublicsetParameterGet(string | array $name, string $value = null) : \Zend_Http_Client
inherited

Set a GET parameter for the request.

Inherited from: \Zend_Http_Client::setParameterGet()

Wrapper around _setParameter

Parameters
NameTypeDescription
$namestring | array
$valuestring
Returns
TypeDescription
\Zend_Http_Client
methodpublicsetParameterPost(string | array $name, string $value = null) : \Zend_Http_Client
inherited

Set a POST parameter for the request.

Inherited from: \Zend_Http_Client::setParameterPost()

Wrapper around _setParameter

Parameters
NameTypeDescription
$namestring | array
$valuestring
Returns
TypeDescription
\Zend_Http_Client
methodpublicsetRawData(string | resource $data, string $enctype = null) : \Zend_Http_Client
inherited

Set the raw (already encoded) POST data.

Inherited from: \Zend_Http_Client::setRawData()

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.

$data can also be stream (such as file) from which the data will be read.

Parameters
NameTypeDescription
$datastring | resource
$enctypestring
Returns
TypeDescription
\Zend_Http_Client
methodpublicsetRawDataStream(string $data, string $enctype = null) : \Zend_Http_Client

Set the raw (already encoded) POST data from a stream source.

This is used to support POSTing from open file handles without caching the entire body into memory. It is a wrapper around Zend_Http_Client::setRawData().

Parameters
NameTypeDescription
$datastring

The request data

$enctypestring

The encoding type

Returns
TypeDescription
\Zend_Http_Client
methodpublicsetStream(string | boolean $streamfile = true) : \Zend_Http_Client
inherited

Set streaming for received data

Inherited from: \Zend_Http_Client::setStream()
Parameters
NameTypeDescription
$streamfilestring | boolean

Stream file, true for temp file, false/null for no streaming

Returns
TypeDescription
\Zend_Http_Client
methodpublicsetStreamingRequest(boolean $value) : void

Set the streamingRequest variable which controls whether we are sending the raw (already encoded) POST data from a stream source.

Parameters
NameTypeDescription
$valueboolean

The value to set.

methodpublicsetUnmaskStatus(boolean $status = true) : \Zend_Http_Client
inherited

Set the unmask feature for GET parameters as array

Inherited from: \Zend_Http_Client::setUnmaskStatus()

Example: foo%5B0%5D=a&foo%5B1%5D=b becomes foo=a&foo=b

This is usefull for some services

Parameters
NameTypeDescription
$statusboolean
Returns
TypeDescription
\Zend_Http_Client
methodpublicsetUri(\Zend_Uri_Http | string $uri) : \Zend_Http_Client
inherited

Set the URI for the next request

Inherited from: \Zend_Http_Client::setUri()
Parameters
NameTypeDescription
$uri\Zend_Uri_Http | string
Returns
TypeDescription
\Zend_Http_Client
Throws
ExceptionDescription
\Zend_Http_Client_Exception
Documentation was generated by phpDocumentor 2.0.0a12.