Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct ($uri=null, $config=null) | |
setUri ($uri) | |
getUri ($as_string=false) | |
setConfig ($config=array()) | |
setMethod ($method=self::GET) | |
setHeaders ($name, $value=null) | |
getHeader ($key) | |
setParameterGet ($name, $value=null) | |
setParameterPost ($name, $value=null) | |
getRedirectionsCount () | |
setAuth ($user, $password='', $type=self::AUTH_BASIC) | |
setCookieJar ($cookiejar=true) | |
getCookieJar () | |
setCookie ($cookie, $value=null) | |
setFileUpload ($filename, $formname, $data=null, $ctype=null) | |
setEncType ($enctype=self::ENC_URLENCODED) | |
setRawData ($data, $enctype=null) | |
setUnmaskStatus ($status=true) | |
getUnmaskStatus () | |
resetParameters ($clearAll=false) | |
getLastRequest () | |
getLastResponse () | |
setAdapter ($adapter) | |
getAdapter () | |
setStream ($streamfile=true) | |
getStream () | |
request ($method=null) | |
Static Public Member Functions | |
static | encodeFormData ($boundary, $name, $value, $filename=null, $headers=array()) |
static | encodeAuthHeader ($user, $password, $type=self::AUTH_BASIC) |
Data Fields | |
const | GET = 'GET' |
const | POST = 'POST' |
const | PUT = 'PUT' |
const | HEAD = 'HEAD' |
const | DELETE = 'DELETE' |
const | TRACE = 'TRACE' |
const | OPTIONS = 'OPTIONS' |
const | CONNECT = 'CONNECT' |
const | MERGE = 'MERGE' |
const | PATCH = 'PATCH' |
const | AUTH_BASIC = 'basic' |
const | HTTP_1 = '1.1' |
const | HTTP_0 = '1.0' |
const | CONTENT_TYPE = 'Content-Type' |
const | CONTENT_LENGTH = 'Content-Length' |
const | ENC_URLENCODED = 'application/x-www-form-urlencoded' |
const | ENC_FORMDATA = 'multipart/form-data' |
const | VTYPE_SCALAR = 'SCALAR' |
const | VTYPE_FILE = 'FILE' |
Protected Member Functions | |
_setParameter ($type, $name, $value) | |
_openTempStream () | |
_prepareHeaders () | |
_prepareBody () | |
_getParametersRecursive ($parray, $urlencode=false) | |
_detectFileMimeType ($file) | |
_validateHeaderValue ($value, $recurse=true) | |
Static Protected Member Functions | |
static | _flattenParametersArray ($parray, $prefix=null) |
Protected Attributes | |
$config | |
$adapter = null | |
$uri = null | |
$headers = array() | |
$method = self::GET | |
$paramsGet = array() | |
$paramsPost = array() | |
$enctype = null | |
$raw_post_data = null | |
$auth | |
$files = array() | |
$body_field_order = array() | |
$cookiejar = null | |
$last_request = null | |
$last_response = null | |
$redirectCounter = 0 | |
$_unmaskStatus = false | |
$_queryBracketsEscaped = true | |
Static Protected Attributes | |
static | $_fileInfoDb = null |
Definition at line 72 of file Client.php.
__construct | ( | $uri = null , |
|
$config = null |
|||
) |
Constructor method. Will create a new HTTP client. Accepts the target URL and optionally configuration array.
Zend_Uri_Http | string | $uri | |
array | $config | Configuration key-value pairs. |
Definition at line 287 of file Client.php.
|
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 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 | File path |
Definition at line 1435 of file Client.php.
|
staticprotected |
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 |
Definition at line 1547 of file Client.php.
|
protected |
Helper method that gets a possibly multi-level parameters array (get or post) and flattens it.
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
array | $parray | The parameters array |
bool | $urlencode | Whether to urlencode the name and value |
Definition at line 1385 of file Client.php.
|
protected |
Create temporary stream
Definition at line 989 of file Client.php.
|
protected |
Prepare the request body (for POST and PUT requests)
Zend_Http_Client_Exception |
Definition at line 1264 of file Client.php.
|
protected |
Prepare the request headers
Definition at line 1183 of file Client.php.
|
protected |
Set a GET or POST parameter - used by SetParameterGet and SetParameterPost
string | $type | GET or POST |
string | $name | |
string | $value |
Definition at line 543 of file Client.php.
|
protected |
Ensure a header value is valid per RFC 7230.
string | object | array | $value | |
bool | $recurse |
Definition at line 1586 of file Client.php.
|
static |
Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
string | $user | |
string | $password | |
string | $type |
Zend_Http_Client_Exception |
Definition at line 1502 of file Client.php.
|
static |
Definition at line 1471 of file Client.php.
getAdapter | ( | ) |
Load the connection adapter
Definition at line 954 of file Client.php.
getCookieJar | ( | ) |
Return the current cookie jar or null if none.
Definition at line 666 of file Client.php.
getHeader | ( | $key | ) |
Get the value of a specific header
Note that if the header has more than one value, an array will be returned.
string | $key |
Definition at line 487 of file Client.php.
getLastRequest | ( | ) |
getLastResponse | ( | ) |
Get the last HTTP response received by this client
If $config['storeresponse'] is set to false, or no response was stored yet, will return null
Definition at line 908 of file Client.php.
getRedirectionsCount | ( | ) |
Get the number of redirections done on the last request
Definition at line 574 of file Client.php.
getStream | ( | ) |
Get status of streaming for received data
Definition at line 979 of file Client.php.
getUnmaskStatus | ( | ) |
Returns the currently configured unmask status
Definition at line 847 of file Client.php.
getUri | ( | $as_string = false | ) |
Get the URI for the next request
boolean | $as_string | If true, will return the URI as a string |
Definition at line 342 of file Client.php.
request | ( | $method = null | ) |
Send the HTTP request and return an HTTP response object
string | $method |
Zend_Http_Client_Exception |
Definition at line 1016 of file Client.php.
resetParameters | ( | $clearAll = false | ) |
Clear all GET and POST parameters
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_*
bool | $clearAll | Should all data be cleared? |
Definition at line 864 of file Client.php.
setAdapter | ( | $adapter | ) |
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
Zend_Http_Client_Adapter_Interface | string | $adapter |
Zend_Http_Client_Exception |
Definition at line 923 of file Client.php.
setAuth | ( | $user, | |
$password = '' , |
|||
$type = self::AUTH_BASIC |
|||
) |
Set HTTP authentication parameters
$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);
string | false | $user | User name or false disable authentication |
string | $password | Password |
string | $type | Authentication type |
Zend_Http_Client_Exception |
Definition at line 602 of file Client.php.
setConfig | ( | $config = array() | ) |
Set configuration parameters for this HTTP client
Zend_Config | array | $config |
Zend_Http_Client_Exception |
Definition at line 358 of file Client.php.
setCookie | ( | $cookie, | |
$value = null |
|||
) |
Add a cookie to the request. If the client has no Cookie Jar, the cookies will be added directly to the headers array as "Cookie" headers.
Zend_Http_Cookie | string | $cookie | |
string | null | $value | If "cookie" is a string, this is the cookie value. |
Zend_Http_Client_Exception |
Definition at line 680 of file Client.php.
setCookieJar | ( | $cookiejar = true | ) |
Set the HTTP client's cookie jar.
A cookie jar is an object that holds and maintains cookies across HTTP requests and responses.
Zend_Http_CookieJar | boolean | $cookiejar | Existing cookiejar object, true to create a new one, false to disable |
Zend_Http_Client_Exception |
Definition at line 642 of file Client.php.
setEncType | ( | $enctype = self::ENC_URLENCODED | ) |
Set the encoding type for POST data
string | $enctype |
Definition at line 788 of file Client.php.
setFileUpload | ( | $filename, | |
$formname, | |||
$data = null , |
|||
$ctype = null |
|||
) |
Set a file to upload (using a POST request)
Can be used in two ways:
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) |
Zend_Http_Client_Exception |
Definition at line 753 of file Client.php.
setHeaders | ( | $name, | |
$value = null |
|||
) |
Set one or more request headers
This function can be used in several ways to set the client's request headers:
string | array | $name | Header name, full header string ('Header: value') or an array of headers |
mixed | $value | Header value or null |
Zend_Http_Client_Exception |
Definition at line 433 of file Client.php.
setMethod | ( | $method = self::GET | ) |
Set the next request's method
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 | $method |
Zend_Http_Client_Exception |
Definition at line 392 of file Client.php.
setParameterGet | ( | $name, | |
$value = null |
|||
) |
Set a GET parameter for the request. Wrapper around _setParameter
string | array | $name | |
string | $value |
Definition at line 504 of file Client.php.
setParameterPost | ( | $name, | |
$value = null |
|||
) |
Set a POST parameter for the request. Wrapper around _setParameter
string | array | $name | |
string | $value |
Definition at line 523 of file Client.php.
setRawData | ( | $data, | |
$enctype = null |
|||
) |
Set the raw (already encoded) POST data.
This function is here for two reasons:
$data can also be stream (such as file) from which the data will be read.
string | resource | $data | |
string | $enctype |
Definition at line 809 of file Client.php.
setStream | ( | $streamfile = true | ) |
Set streaming for received data
string | boolean | $streamfile | Stream file, true for temp file, false/null for no streaming |
Definition at line 969 of file Client.php.
setUnmaskStatus | ( | $status = true | ) |
Set the unmask feature for GET parameters as array
Example: foo%5B0%5D=a&foo%5B1%5D=b becomes foo=a&foo=b
This is usefull for some services
boolean | $status |
Definition at line 836 of file Client.php.
setUri | ( | $uri | ) |
Set the URI for the next request
Zend_Uri_Http | string | $uri |
Zend_Http_Client_Exception |
Definition at line 306 of file Client.php.
|
staticprotected |
Definition at line 278 of file Client.php.
|
protected |
Definition at line 268 of file Client.php.
|
protected |
Definition at line 261 of file Client.php.
|
protected |
Definition at line 143 of file Client.php.
|
protected |
Definition at line 206 of file Client.php.
|
protected |
Definition at line 226 of file Client.php.
|
protected |
Definition at line 123 of file Client.php.
|
protected |
Definition at line 233 of file Client.php.
|
protected |
Definition at line 185 of file Client.php.
|
protected |
Definition at line 216 of file Client.php.
|
protected |
Definition at line 157 of file Client.php.
|
protected |
Definition at line 240 of file Client.php.
|
protected |
Definition at line 247 of file Client.php.
|
protected |
Definition at line 164 of file Client.php.
|
protected |
Definition at line 171 of file Client.php.
|
protected |
Definition at line 178 of file Client.php.
|
protected |
Definition at line 192 of file Client.php.
|
protected |
Definition at line 254 of file Client.php.
|
protected |
Definition at line 150 of file Client.php.
const AUTH_BASIC = 'basic' |
Supported HTTP Authentication methods
Definition at line 91 of file Client.php.
const CONNECT = 'CONNECT' |
Definition at line 84 of file Client.php.
const CONTENT_LENGTH = 'Content-Length' |
Definition at line 104 of file Client.php.
const CONTENT_TYPE = 'Content-Type' |
Content attributes
Definition at line 103 of file Client.php.
const DELETE = 'DELETE' |
Definition at line 81 of file Client.php.
const ENC_FORMDATA = 'multipart/form-data' |
Definition at line 110 of file Client.php.
const ENC_URLENCODED = 'application/x-www-form-urlencoded' |
POST data encoding methods
Definition at line 109 of file Client.php.
const GET = 'GET' |
HTTP request methods
Definition at line 77 of file Client.php.
const HEAD = 'HEAD' |
Definition at line 80 of file Client.php.
const HTTP_0 = '1.0' |
Definition at line 98 of file Client.php.
const HTTP_1 = '1.1' |
HTTP protocol versions
Definition at line 97 of file Client.php.
const MERGE = 'MERGE' |
Definition at line 85 of file Client.php.
const OPTIONS = 'OPTIONS' |
Definition at line 83 of file Client.php.
const PATCH = 'PATCH' |
Definition at line 86 of file Client.php.
const POST = 'POST' |
Definition at line 78 of file Client.php.
const PUT = 'PUT' |
Definition at line 79 of file Client.php.
const TRACE = 'TRACE' |
Definition at line 82 of file Client.php.
const VTYPE_FILE = 'FILE' |
Definition at line 116 of file Client.php.
const VTYPE_SCALAR = 'SCALAR' |
Value types for Body key/value pairs
Definition at line 115 of file Client.php.