Zend\Http\Client
Http client
Synopsis
class Client
implements
DispatchableInterface
{
- // constants
- const AUTH_BASIC = 'basic';
- const AUTH_DIGEST = 'digest';
- const ENC_URLENCODED = 'application/x-www-form-urlencoded';
- const ENC_FORMDATA = 'multipart/form-data';
- const DIGEST_REALM = 'realm';
- const DIGEST_QOP = 'qop';
- const DIGEST_NONCE = 'nonce';
- const DIGEST_OPAQUE = 'opaque';
- const DIGEST_NC = 'nc';
- const DIGEST_CNONCE = 'cnonce';
- // members
- protected Response $response;
- protected Request $request;
- protected Client/Adapter $adapter;
- protected array $auth;
- protected string $streamName;
- protected array $cookies;
- protected string $encType;
- protected Request $lastRawRequest;
- protected Response $lastRawResponse;
- protected integer $redirectCounter;
- protected array $config;
- protected resource $fileInfoDb;
- // methods
- public void __construct()
- public Client setOptions()
- public Client setAdapter()
- public AdapterInterface getAdapter()
- public Client setRequest()
- public Request getRequest()
- public Client setResponse()
- public Response getResponse()
- public string getLastRawRequest()
- public string getLastRawResponse()
- public int getRedirectionsCount()
- public Client setUri()
- public Http getUri()
- public Client setMethod()
- public string getMethod()
- public Client setArgSeparator()
- public string getArgSeparator()
- public Client setEncType()
- public string getEncType()
- public Client setRawBody()
- public Client setParameterPost()
- public Client setParameterGet()
- public Client resetParameters()
- public array getCookies()
- protected string|bool getCookieId()
- public Client addCookie()
- public Client setCookies()
- public void clearCookies()
- public Client setHeaders()
- public bool hasHeader()
- public string|bool getHeader()
- public Client setStream()
- public bool|string getStream()
- protected resource openTempStream()
- public Client setAuth()
- public void clearAuth()
- protected string|bool calcAuthDigest()
- public ResponseInterface dispatch()
- public Response send()
- public Client reset()
- public Client setFileUpload()
- public bool removeFileUpload()
- protected Cookie|bool prepareCookies()
- protected array prepareHeaders()
- protected string prepareBody()
- protected string detectFileMimeType()
- public string encodeFormData()
- protected array flattenParametersArray()
- protected string doRequest()
- public static string encodeAuthHeader()
Hierarchy
Implements
Constants
Name | Value |
---|---|
AUTH_BASIC | 'basic' |
AUTH_DIGEST | 'digest' |
ENC_URLENCODED | 'application/x-www-form-urlencoded' |
ENC_FORMDATA | 'multipart/form-data' |
DIGEST_REALM | 'realm' |
DIGEST_QOP | 'qop' |
DIGEST_NONCE | 'nonce' |
DIGEST_OPAQUE | 'opaque' |
DIGEST_NC | 'nc' |
DIGEST_CNONCE | 'cnonce' |
Members
protected
- $adapter — Zend\Http\Client/Adapter
- $auth — array
- $config
—
array
Configuration array, set using the constructor or using ::setOptions() - $encType — string
- $fileInfoDb
—
resource
Fileinfo magic database resource - $lastRawRequest — Zend\Http\Request
- $lastRawResponse — Zend\Http\Response
- $redirectCounter — int
- $request — Zend\Http\Request
- $response — Zend\Http\Response
- $streamName — string
Methods
protected
- calcAuthDigest() — Calculate the response value according to the HTTP authentication type
- detectFileMimeType() — Attempt to detect the MIME type of a file using available extensions
- doRequest() — Separating this from send method allows subclasses to wrap the interaction with the adapter
- flattenParametersArray() — Convert an array of parameters into a flat array of (key, value) pairs
- getCookieId() — Get the cookie Id (name+domain+path)
- openTempStream() — Create temporary stream
- prepareBody() — Prepare the request body (for PATCH, POST and PUT requests)
- prepareCookies() — Prepare Cookies
- prepareHeaders() — Prepare the request headers
public
- __construct() — Constructor
- addCookie() — Add a cookie
- clearAuth() — Clear http authentication
- clearCookies() — Clear all the cookies
- dispatch() — Dispatch
- encodeAuthHeader() — Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
- encodeFormData() — Encode data to a multipart/form-data part suitable for a POST request.
- getAdapter() — Load the connection adapter
- getArgSeparator() — Get the query string argument separator
- getCookies() — Return the current cookies
- getEncType() — Get the encoding type
- getHeader() — Get the header value of the request
- 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
- getRequest() — Get Request
- getResponse() — Get Response
- getStream() — Get status of streaming for received data
- getUri() — Get uri (from the request)
- hasHeader() — Check if exists the header type specified
- removeFileUpload() — Remove a file to upload
- reset() — Fully reset the HTTP client (auth, cookies, request, response, etc.)
- resetParameters() — Reset all the HTTP parameters (request, response, etc)
- send() — Send HTTP request
- setAdapter() — Load the connection adapter
- setArgSeparator() — Set the query string argument separator
- setAuth() — Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
- setCookies() — Set an array of cookies
- setEncType() — Set the encoding type and the boundary (if any)
- setFileUpload() — Set a file to upload (using a POST request)
- setHeaders() — Set the headers (for the request)
- setMethod() — Set the HTTP method (to the request)
- setOptions() — Set configuration parameters for this HTTP client
- setParameterGet() — Set the GET parameters
- setParameterPost() — Set the POST parameters
- setRawBody() — Set raw body (for advanced use cases)
- setRequest() — Set request
- setResponse() — Set response
- setStream() — Set streaming for received data
- setUri() — Set Uri (to the request)