Zend Framework
3.0
|
Public Member Functions | |
__construct ($uri=null, $options=null) | |
Constructor. | |
setOptions ($options=[]) | |
Set configuration parameters for this HTTP client. | |
setAdapter ($adapter) | |
Load the connection adapter. | |
getAdapter () | |
Load the connection adapter. | |
setRequest (Request $request) | |
Set request. | |
getRequest () | |
Get Request. | |
setResponse (Response $response) | |
Set response. | |
getResponse () | |
Get Response. | |
getLastRawRequest () | |
Get the last request (as a string) | |
getLastRawResponse () | |
Get the last response (as a string) | |
getRedirectionsCount () | |
Get the redirections count. | |
setUri ($uri) | |
Set Uri (to the request) | |
getUri () | |
Get uri (from the request) | |
setMethod ($method) | |
Set the HTTP method (to the request) | |
getMethod () | |
Get the HTTP method. | |
setArgSeparator ($argSeparator) | |
Set the query string argument separator. | |
getArgSeparator () | |
Get the query string argument separator. | |
setEncType ($encType, $boundary=null) | |
Set the encoding type and the boundary (if any) | |
getEncType () | |
Get the encoding type. | |
setRawBody ($body) | |
Set raw body (for advanced use cases) | |
setParameterPost (array $post) | |
Set the POST parameters. | |
setParameterGet (array $query) | |
Set the GET parameters. | |
resetParameters ($clearCookies=false) | |
Reset all the HTTP parameters (request, response, etc) | |
getCookies () | |
Return the current cookies. | |
addCookie ($cookie, $value=null, $expire=null, $path=null, $domain=null, $secure=false, $httponly=true, $maxAge=null, $version=null) | |
Add a cookie. | |
setCookies ($cookies) | |
Set an array of cookies. | |
clearCookies () | |
Clear all the cookies. | |
setHeaders ($headers) | |
Set the headers (for the request) | |
hasHeader ($name) | |
Check if exists the header type specified. | |
getHeader ($name) | |
Get the header value of the request. | |
setStream ($streamfile=true) | |
Set streaming for received data. | |
getStream () | |
Get status of streaming for received data. | |
setAuth ($user, $password, $type=self::AUTH_BASIC) | |
Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method. | |
clearAuth () | |
Clear http authentication. | |
dispatch (Stdlib\RequestInterface $request, Stdlib\ResponseInterface $response=null) | |
Dispatch. | |
send (Request $request=null) | |
Send HTTP request. | |
reset () | |
Fully reset the HTTP client (auth, cookies, request, response, etc.) | |
setFileUpload ($filename, $formname, $data=null, $ctype=null) | |
Set a file to upload (using a POST request) | |
removeFileUpload ($filename) | |
Remove a file to upload. | |
encodeFormData ($boundary, $name, $value, $filename=null, $headers=[]) | |
Public Member Functions inherited from DispatchableInterface | |
dispatch (RequestInterface $request, ResponseInterface $response=null) | |
Dispatch a request. | |
Static Public Member Functions | |
static | encodeAuthHeader ($user, $password, $type=self::AUTH_BASIC) |
Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method. | |
Public Attributes | |
const | AUTH_BASIC = 'basic' |
string Supported HTTP Authentication methods | |
const | AUTH_DIGEST = 'digest' |
const | ENC_URLENCODED = 'application/x-www-form-urlencoded' |
string POST data encoding methods | |
const | ENC_FORMDATA = 'multipart/form-data' |
const | DIGEST_REALM = 'realm' |
string DIGEST Authentication | |
const | DIGEST_QOP = 'qop' |
const | DIGEST_NONCE = 'nonce' |
const | DIGEST_OPAQUE = 'opaque' |
const | DIGEST_NC = 'nc' |
const | DIGEST_CNONCE = 'cnonce' |
Protected Member Functions | |
getCookieId ($cookie) | |
Get the cookie Id (name+domain+path) | |
openTempStream () | |
Create temporary stream. | |
calcAuthDigest ($user, $password, $type=self::AUTH_BASIC, $digest=[], $entityBody=null) | |
Calculate the response value according to the HTTP authentication type. | |
prepareCookies ($domain, $path, $secure) | |
Prepare Cookies. | |
prepareHeaders ($body, $uri) | |
Prepare the request headers. | |
prepareBody () | |
Prepare the request body (for PATCH, POST and PUT requests) | |
detectFileMimeType ($file) | |
Attempt to detect the MIME type of a file using available extensions. | |
flattenParametersArray ($parray, $prefix=null) | |
Convert an array of parameters into a flat array of (key, value) pairs. | |
doRequest (Http $uri, $method, $secure=false, $headers=[], $body= '') | |
Separating this from send method allows subclasses to wrap the interaction with the adapter. | |
Protected Attributes | |
$response | |
$request | |
$adapter | |
$auth = [] | |
$streamName = null | |
$cookies = [] | |
$encType = '' | |
$lastRawRequest = null | |
$lastRawResponse = null | |
$redirectCounter = 0 | |
$config | |
Static Protected Attributes | |
static | $fileInfoDb = null |
Http client.
__construct | ( | $uri = null , |
|
$options = null |
|||
) |
Constructor.
string | $uri | |
array | Traversable | $options |
addCookie | ( | $cookie, | |
$value = null , |
|||
$expire = null , |
|||
$path = null , |
|||
$domain = null , |
|||
$secure = false , |
|||
$httponly = true , |
|||
$maxAge = null , |
|||
$version = null |
|||
) |
Add a cookie.
array | ArrayIterator | Header\SetCookie | string | $cookie | |
string | $value | |
string | $expire | |
string | $path | |
string | $domain | |
bool | $secure | |
bool | $httponly | |
string | $maxAge | |
string | $version |
Exception\InvalidArgumentException |
|
protected |
Calculate the response value according to the HTTP authentication type.
string | $user | |
string | $password | |
string | $type | |
array | $digest | |
null | string | $entityBody |
Exception\InvalidArgumentException |
clearAuth | ( | ) |
Clear http authentication.
clearCookies | ( | ) |
Clear all the cookies.
|
protected |
Attempt to detect the MIME type of a file using available extensions.
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
string | $file | File path |
dispatch | ( | Stdlib\RequestInterface | $request, |
Stdlib\ResponseInterface | $response = null |
||
) |
Dispatch.
Stdlib\RequestInterface | $request | |
Stdlib\ResponseInterface | $response |
|
protected |
Separating this from send method allows subclasses to wrap the interaction with the adapter.
Http | $uri | |
string | $method | |
bool | $secure | |
array | $headers | |
string | $body |
Exception\RuntimeException |
|
static |
Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
string | $user | |
string | $password | |
string | $type |
Client\Exception\InvalidArgumentException |
encodeFormData | ( | $boundary, | |
$name, | |||
$value, | |||
$filename = null , |
|||
$headers = [] |
|||
) |
|
protected |
Convert an array of parameters into a flat array of (key, value) pairs.
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.
array | $parray | |
string | $prefix |
getAdapter | ( | ) |
Load the connection adapter.
getArgSeparator | ( | ) |
Get the query string argument separator.
|
protected |
Get the cookie Id (name+domain+path)
Header\SetCookie | Header\Cookie | $cookie |
getCookies | ( | ) |
Return the current cookies.
getEncType | ( | ) |
Get the encoding type.
getHeader | ( | $name | ) |
Get the header value of the request.
string | $name |
getLastRawRequest | ( | ) |
Get the last request (as a string)
getLastRawResponse | ( | ) |
Get the last response (as a string)
getMethod | ( | ) |
Get the HTTP method.
getRedirectionsCount | ( | ) |
Get the redirections count.
getStream | ( | ) |
Get status of streaming for received data.
getUri | ( | ) |
Get uri (from the request)
hasHeader | ( | $name | ) |
Check if exists the header type specified.
string | $name |
|
protected |
Create temporary stream.
Exception\RuntimeException |
|
protected |
Prepare the request body (for PATCH, POST and PUT requests)
\Zend\Http\Client\Exception\RuntimeException |
|
protected |
|
protected |
Prepare the request headers.
resource | string | $body | |
Http | $uri |
Exception\RuntimeException |
removeFileUpload | ( | $filename | ) |
Remove a file to upload.
string | $filename |
reset | ( | ) |
Fully reset the HTTP client (auth, cookies, request, response, etc.)
resetParameters | ( | $clearCookies = false | ) |
Reset all the HTTP parameters (request, response, etc)
bool | $clearCookies | Also clear all valid cookies? (defaults to false) |
bool | $clearAuth | Also clear http authentication? (defaults to true) |
send | ( | Request | $request = null | ) |
setAdapter | ( | $adapter | ) |
Load the connection adapter.
While this method is not called more than one for a client, it is separated from ->request() to preserve logic and readability
Client\Adapter\AdapterInterface | string | $adapter |
Client\Exception\InvalidArgumentException |
setArgSeparator | ( | $argSeparator | ) |
setAuth | ( | $user, | |
$password, | |||
$type = self::AUTH_BASIC |
|||
) |
Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
string | $user | |
string | $password | |
string | $type |
Exception\InvalidArgumentException |
setCookies | ( | $cookies | ) |
Set an array of cookies.
array | $cookies |
Exception\InvalidArgumentException |
setEncType | ( | $encType, | |
$boundary = null |
|||
) |
Set the encoding type and the boundary (if any)
string | $encType | |
string | $boundary |
setFileUpload | ( | $filename, | |
$formname, | |||
$data = null , |
|||
$ctype = null |
|||
) |
Set a file to upload (using a POST request)
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.
string | $filename | Name of file to upload, or name to save as |
string | $formname | Name of form element to send as |
string | $data | Data to send (if null, $filename is read and sent) |
string | $ctype | Content type to use (if $data is set and $ctype is null, will be application/octet-stream) |
Exception\RuntimeException |
setHeaders | ( | $headers | ) |
setMethod | ( | $method | ) |
setOptions | ( | $options = [] | ) |
setParameterGet | ( | array | $query | ) |
setParameterPost | ( | array | $post | ) |
setRawBody | ( | $body | ) |
setStream | ( | $streamfile = true | ) |
Set streaming for received data.
string | bool | $streamfile | Stream file, true for temp file, false/null for no streaming |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
const AUTH_BASIC = 'basic' |
string Supported HTTP Authentication methods
const AUTH_DIGEST = 'digest' |
const DIGEST_CNONCE = 'cnonce' |
const DIGEST_NC = 'nc' |
const DIGEST_NONCE = 'nonce' |
const DIGEST_OPAQUE = 'opaque' |
const DIGEST_QOP = 'qop' |
const DIGEST_REALM = 'realm' |
string DIGEST Authentication
const ENC_FORMDATA = 'multipart/form-data' |
const ENC_URLENCODED = 'application/x-www-form-urlencoded' |
string POST data encoding methods