Methods
Constructor
__construct(string $uri, array | \Traversable $options)
Parameters
$uri
string
$options
array\Traversable
Add a cookie
addCookie(array | \ArrayIterator | \Zend\Http\Header\SetCookie | string $cookie, string $value, string $expire, string $path, string $domain, bool $secure, bool $httponly, string $maxAge, string $version) : \Zend\Http\Client
Parameters
$value
string
$expire
string
$path
string
$domain
string
$secure
bool
$httponly
bool
$maxAge
string
$version
string
Exceptions
Returns
Clear http authentication
clearAuth()
Clear all the cookies
clearCookies()
Get the query string argument separator
getArgSeparator() : string
Return the current cookies
getCookies() : array
Get the encoding type
getEncType() : string
Get the last request (as a string)
getLastRawRequest() : string
Get the last response (as a string)
getLastRawResponse() : string
Get the HTTP method
getMethod() : string
Get the redirections count
getRedirectionsCount() : int
Get status of streaming for received data
getStream() : bool | string
Remove a file to upload
removeFileUpload(string $filename) : bool
Parameters
$filename
string
Returns
bool
Fully reset the HTTP client (auth, cookies, request, response, etc.)
reset() : \Zend\Http\Client
Reset all the HTTP parameters (request, response, etc)
resetParameters(bool $clearCookies) : \Zend\Http\Client
Parameters
$clearCookies
bool
Also clear all valid cookies? (defaults to false)
Returns
Send HTTP request
send(\Zend\Http\Request $request) : \Zend\Http\Response
Parameters
Exceptions
Returns
Set the query string argument separator
setArgSeparator(string $argSeparator) : \Zend\Http\Client
Parameters
$argSeparator
string
Returns
Create a HTTP authentication "Authorization:" header according to the
specified user, password and authentication method.
setAuth(string $user, string $password, string $type) : \Zend\Http\Client
Parameters
$user
string
$password
string
$type
string
Exceptions
Returns
Set an array of cookies
setCookies(array $cookies) : \Zend\Http\Client
Parameters
$cookies
array
Exceptions
Returns
Set the encoding type and the boundary (if any)
setEncType(string $encType, string $boundary) : \Zend\Http\Client
Parameters
$encType
string
$boundary
string
Returns
Set a file to upload (using a POST request)
setFileUpload(string $filename, string $formname, string $data, string $ctype) : \Zend\Http\Client
Can be used in two ways:
- $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().
- $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
$filename
string
Name of file to upload, or name to save as
$formname
string
Name of form element to send as
$data
string
Data to send (if null, $filename is read and sent)
$ctype
string
Content type to use (if $data is set and $ctype is null, will be application/octet-stream)
Exceptions
Returns
Set the HTTP method (to the request)
setMethod(string $method) : \Zend\Http\Client
Parameters
$method
string
Returns
Set configuration parameters for this HTTP client
setOptions(array | \Traversable $options) : \Zend\Http\Client
Parameters
$options
array\Traversable
Exceptions
Returns
Set the GET parameters
setParameterGet(array $query) : \Zend\Http\Client
Parameters
$query
array
Returns
Set the POST parameters
setParameterPost(array $post) : \Zend\Http\Client
Parameters
$post
array
Returns
Set raw body (for advanced use cases)
setRawBody(string $body) : \Zend\Http\Client
Parameters
$body
string
Returns
Set streaming for received data
setStream(string | bool $streamfile) : \Zend\Http\Client
Parameters
$streamfile
stringbool
Stream file, true for temp file, false/null for no streaming
Returns
Calculate the response value according to the HTTP authentication type
calcAuthDigest(string $user, string $password, string $type, array $digest, null | string $entityBody) : string | bool
see |
\Zend\Http\http://www.faqs.org/rfcs/rfc2617.html |
Parameters
$user
string
$password
string
$type
string
$digest
array
$entityBody
nullstring
Exceptions
Returns
string
bool
Attempt to detect the MIME type of a file using available extensions
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 deprecated 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
Returns
string
MIME type
Separating this from send method allows subclasses to wrap
the interaction with the adapter
doRequest(\Zend\Uri\Http $uri, string $method, bool $secure, array $headers, string $body) : string
Parameters
$method
string
$secure
bool
$headers
array
$body
string
Exceptions
Returns
string
the raw response
Convert an array of parameters into a flat array of (key, value) pairs
flattenParametersArray(array $parray, string $prefix) : 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.
Parameters
$parray
array
$prefix
string
Returns
array
Create temporary stream
openTempStream() : resource
Exceptions
Returns
resource
Prepare the request body (for PATCH, POST and PUT requests)
prepareBody() : string
Exceptions
Returns
string
Prepare Cookies
prepareCookies(string $domain, string $path, bool $secure) : \Zend\Http\Header\Cookie | bool
Parameters
$domain
string
$path
string
$secure
bool
Returns
Properties
Configuration array, set using the constructor or using ::setOptions()
$config : array
<p>of Header\SetCookie</p>
$cookies : array
$encType
$encType : string
Fileinfo magic database resource
$fileInfoDb : resource
This variable is populated the first time _detectFileMimeType is called
and is then reused on every call to this method
$redirectCounter
$redirectCounter : int
$streamName
$streamName : string
Constants
AUTH_BASIC
AUTH_BASIC
const |
string Supported HTTP Authentication methods |
DIGEST_CNONCE
DIGEST_CNONCE
DIGEST_NONCE
DIGEST_NONCE
DIGEST_OPAQUE
DIGEST_OPAQUE
DIGEST_REALM
DIGEST_REALM
const |
string DIGEST Authentication |
ENC_URLENCODED
ENC_URLENCODED
const |
string POST data encoding methods |