Gdata Http Client object.
Class to extend the generic Zend Http Client with the ability to perform secure AuthSub requests
category | Zend |
---|---|
package | Zend_Gdata |
subpackage | Gdata |
copyright | Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
license | New BSD License |
inherited_from | \Zend_Http_Client |
__construct(\Zend_Uri_Http|string $uri= null
, array $config= null
)
\Zend_Uri_Http
string
array
Configuration key-value pairs.
encodeAuthHeader(string $user, string $password, string $type = self::AUTH_BASIC
) : string
encodeFormData(string $boundary, string $name, mixed $value, string $filename= null
, array $headers= array()
) : string
string
string
mixed
string
array
Associative array of optional headers @example ("Content-Transfer-Encoding" => "binary")
string
filterHttpRequest(string $method, string $url, array $headers= array()
, string $body= null
, string $contentType= null
) : array
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.
string
The HTTP method
string
The URL
array
An associate array of headers to be sent with the request or null
string
The body of the request or null
string
The MIME content type of the body or null
\Zend_Gdata_App_Exception |
if there was a signing failure |
---|
array
The processed values in an associative array,
using the same names as the paramsfilterHttpResponse(\Zend_Http_Response $response) : \Zend_Http_Response
\Zend_Http_Response
The response object to filter
\Zend_Http_Response
The filterd response objectgetAdapter() : \Zend_Http_Client_Adapter_Interface | string
inherited_from | \Zend_Http_Client::getAdapter() |
---|
\Zend_Http_Client_Adapter_Interface
string
$adaptergetAdapter() : \Zend_Http_Client_Adapter_Interface
\Zend_Http_Client_Adapter_Interface
$adaptergetAuthSubPrivateKeyId() : string
string
The private keygetAuthSubToken() : string
string
The tokengetClientLoginToken() : string
string
The tokengetCookieJar() : \Zend_Http_CookieJar | null
\Zend_Http_CookieJar
null
getHeader(string $key) : string | array | null
Note that if the header has more than one value, an array will be returned.
string
string
array
null
The header value or null if it is not setgetLastRequest() : string
string
getLastResponse() : \Zend_Http_Response
If $config['storeresponse'] is set to false, or no response was stored yet, will return null
\Zend_Http_Response
or null if nonegetRedirectionsCount() : integer
integer
getStream() : boolean | string
boolean
string
getStreamingRequest() : boolean
boolean
True if yes, false otherwise.getUnmaskStatus() : boolean
boolean
getUri(boolean $as_string = false
) : \Zend_Uri_Http | string
boolean
If true, will return the URI as a string
\Zend_Uri_Http
string
request(string $method = null
) : \Zend_Http_Response
string
\Zend_Http_Client_Exception |
---|
\Zend_Http_Response
resetParameters(boolean $clearAll = false
) : \Zend_Http_Client
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_*
inherited_from | \Zend_Http_Client::resetParameters() |
---|
\Zend_Http_Client
resetParameters(boolean $clearAll = false
) : \Zend_Http_Client
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_*
boolean
Should all data be cleared?
\Zend_Http_Client
setAdapter(\Zend_Http_Client_Adapter_Interface $adapter) : void
While this method is not called more than one for a client, it is seperated from ->request() to preserve logic and readability
inherited_from | \Zend_Http_Client::setAdapter() |
---|
\Zend_Http_Client_Adapter_Interface
setAdapter(\Zend_Http_Client_Adapter_Interface|string $adapter) : null
While this method is not called more than one for a client, it is seperated from ->request() to preserve logic and readability
\Zend_Http_Client_Adapter_Interface
string
\Zend_Http_Client_Exception |
---|
null
setAuth(string|false $user, string $password= ''
, string $type= self::AUTH_BASIC
) : \Zend_Http_Client
$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);
see |
---|
string
false
User name or false disable authentication
string
Password
string
Authentication type
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
setAuthSubPrivateKey(string $key, string $passphrase = null
) : \Zend_Gdata_HttpClient
In order to call this method, openssl must be enabled in your PHP installation. Otherwise, a Zend_Gdata_App_InvalidArgumentException will be thrown.
string
The private key
string
The optional private key passphrase
\Zend_Gdata_App_InvalidArgumentException |
---|
\Zend_Gdata_HttpClient
Provides a fluent interfacesetAuthSubPrivateKeyFile(string $file, string $passphrase= null
, boolean $useIncludePath= false
) : void
This method reads the file and then calls setAuthSubPrivateKey() with the file contents.
string
The location of the file containing the PEM key
string
The optional private key passphrase
boolean
Whether to search the include_path for the file
setAuthSubToken(string $token) : \Zend_Gdata_HttpClient
string
The token
\Zend_Gdata_HttpClient
Provides a fluent interfacesetClientLoginToken(string $token) : \Zend_Gdata_HttpClient
string
The token
\Zend_Gdata_HttpClient
Provides a fluent interfacesetConfig($config = array()
) : \Zend_Http_Client
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
setCookie(\Zend_Http_Cookie|string $cookie, string|null $value = null
) : \Zend_Http_Client
\Zend_Http_Cookie
string
string
null
If "cookie" is a string, this is the cookie value.
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
setCookieJar(\Zend_Http_CookieJar|boolean $cookiejar = true
) : \Zend_Http_Client
A cookie jar is an object that holds and maintains cookies across HTTP requests and responses.
\Zend_Http_CookieJar
boolean
Existing cookiejar object, true to create a new one, false to disable
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
setEncType(string $enctype = self::ENC_URLENCODED
) : \Zend_Http_Client
string
\Zend_Http_Client
setFileUpload(string $filename, string $formname, string $data= null
, string $ctype= null
) : \Zend_Http_Client
Can be used in two ways:
string
Name of file to upload, or name to save as
string
Name of form element to send as
string
Data to send (if null, $filename is read and sent)
string
Content type to use (if $data is set and $ctype is null, will be application/octet-stream)
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
setHeaders(string|array $name, mixed $value = null
) : \Zend_Http_Client
This function can be used in several ways to set the client's request headers:
string
array
Header name, full header string ('Header: value') or an array of headers
mixed
Header value or null
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
setMethod(string $method = self::GET
) : \Zend_Http_Client
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.
string
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
setParameterGet(string|array $name, string $value = null
) : \Zend_Http_Client
string
array
string
\Zend_Http_Client
setParameterPost(string|array $name, string $value = null
) : \Zend_Http_Client
string
array
string
\Zend_Http_Client
setRawData(string|resource $data, string $enctype = null
) : \Zend_Http_Client
This function is here for two reasons:
$data can also be stream (such as file) from which the data will be read.
string
resource
string
\Zend_Http_Client
setRawDataStream(string $data, string $enctype = null
) : \Zend_Http_Client
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().
string
The request data
string
The encoding type
\Zend_Http_Client
setStream(string|boolean $streamfile = true
) : \Zend_Http_Client
string
boolean
Stream file, true for temp file, false/null for no streaming
\Zend_Http_Client
setStreamingRequest(boolean $value) : void
boolean
The value to set.
setUnmaskStatus(boolean $status = true
) : \Zend_Http_Client
Example: foo%5B0%5D=a&foo%5B1%5D=b becomes foo=a&foo=b
This is usefull for some services
boolean
\Zend_Http_Client
setUri(\Zend_Uri_Http|string $uri) : \Zend_Http_Client
\Zend_Uri_Http
string
\Zend_Http_Client_Exception |
---|
\Zend_Http_Client
_detectFileMimeType(string $file) : string
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
string
File path
string
MIME type_flattenParametersArray(array $parray, string $prefix = null
) : array
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.
since | 1.9 |
---|
array
string
array
_getParametersRecursive(array $parray, boolean $urlencode = false
) : array
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
deprecated | since 1.9 |
---|
array
The parameters array
boolean
Whether to urlencode the name and value
array
_openTempStream() : resource
resource
_prepareBody() : string
inherited_from | \Zend_Http_Client::_prepareBody() |
---|
\Zend_Http_Client_Exception |
---|
string
_prepareBody() : string
\Zend_Http_Client_Exception |
---|
string
_prepareHeaders() : array
array
_setParameter(string $type, string $name, string $value) : null
string
GET or POST
string
string
null
_validateHeaderValue(string|object|array $value, boolean $recurse = true
)
$_fileInfoDb : resource
null
This variable is populated the first time _detectFileMimeType is called and is then reused on every call to this method
$_queryBracketsEscaped : boolean
true
$_streamingRequest : boolean
null
$_unmaskStatus : boolean
false
$adapter : \Zend_Http_Client_Adapter_Interface
null
$auth : array | null
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.
$body_field_order : array
array()
An associative array, where each element is of the format:
'
$config : array
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)
$enctype : string
null
$files : array
array()
An associative array, where each element is of the format: 'name' => array('filename.txt', 'text/plain', 'This is the actual file contents')
$headers : array
array()
$last_request : string
null
$last_response : \Zend_Http_Response
null
$method : string
self::GET
$paramsGet : array
array()
$paramsPost : array
array()
$raw_post_data : string
null
$redirectCounter : integer
0
$uri : \Zend_Uri_Http
null
$_authSubPrivateKeyId : resource
null
$_authSubToken : string
null
If this token is set, AuthSub authentication is used.
$_clientLoginKey : string
null
If this token is set, and the AuthSub key is not set, ClientLogin authentication is used
$_clientLoginToken : string
null
If only this token is set, ClientLogin authentication is used.
AUTH_BASIC = 'basic'
CONNECT = 'CONNECT'
CONTENT_LENGTH = 'Content-Length'
CONTENT_TYPE = 'Content-Type'
DELETE = 'DELETE'
ENC_FORMDATA = 'multipart/form-data'
ENC_URLENCODED = 'application/x-www-form-urlencoded'
GET = 'GET'
HEAD = 'HEAD'
HTTP_0 = '1.0'
HTTP_1 = '1.1'
MERGE = 'MERGE'
OPTIONS = 'OPTIONS'
PATCH = 'PATCH'
POST = 'POST'
PUT = 'PUT'
TRACE = 'TRACE'
VTYPE_FILE = 'FILE'
VTYPE_SCALAR = 'SCALAR'