Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
Zend_Oauth_Client Class Reference
Inheritance diagram for Zend_Oauth_Client:
Zend_Http_Client

Public Member Functions

 __construct ($oauthOptions, $uri=null, $config=null)
 
 setAdapter ($adapter)
 
 setStreamingRequest ($value)
 
 getStreamingRequest ()
 
 resetParameters ($clearAll=false)
 
 setRawDataStream ($data, $enctype=null)
 
 setMethod ($method=self::GET)
 
 request ($method=null)
 
 prepareOauth ()
 
 __call ($method, array $args)
 
- Public Member Functions inherited from Zend_Http_Client
 __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 Attributes

static $supportsRevisionA = false
 

Protected Member Functions

 _prepareBody ()
 
 _getSignableParametersAsQueryString ()
 
- Protected Member Functions inherited from Zend_Http_Client
 _setParameter ($type, $name, $value)
 
 _openTempStream ()
 
 _prepareHeaders ()
 
 _prepareBody ()
 
 _getParametersRecursive ($parray, $urlencode=false)
 
 _detectFileMimeType ($file)
 
 _validateHeaderValue ($value, $recurse=true)
 

Protected Attributes

 $_config = null
 
 $_streamingRequest = null
 
- Protected Attributes inherited from Zend_Http_Client
 $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
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Http_Client
static encodeFormData ($boundary, $name, $value, $filename=null, $headers=array())
 
static encodeAuthHeader ($user, $password, $type=self::AUTH_BASIC)
 
- Data Fields inherited from Zend_Http_Client
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'
 
- Static Protected Member Functions inherited from Zend_Http_Client
static _flattenParametersArray ($parray, $prefix=null)
 
- Static Protected Attributes inherited from Zend_Http_Client
static $_fileInfoDb = null
 

Detailed Description

Definition at line 40 of file Client.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $oauthOptions,
  $uri = null,
  $config = null 
)

Constructor; creates a new HTTP Client instance which itself is just a typical Zend_Http_Client subclass with some OAuth icing to assist in automating OAuth parameter generation, addition and cryptographioc signing of requests.

Parameters
array | Zend_Config$oauthOptions
string$uri
array | Zend_Config$config
Returns
void

Definition at line 77 of file Client.php.

78  {
79  if ($config instanceof Zend_Config && !isset($config->rfc3986_strict)) {
80  $config = $config->toArray();
81  $config['rfc3986_strict'] = true;
82  } else if (null === $config ||
83  (is_array($config) && !isset($config['rfc3986_strict']))) {
84  $config['rfc3986_strict'] = true;
85  }
86  parent::__construct($uri, $config);
87  $this->_config = new Zend_Oauth_Config;
88  if ($oauthOptions !== null) {
89  if ($oauthOptions instanceof Zend_Config) {
90  $oauthOptions = $oauthOptions->toArray();
91  }
92  $this->_config->setOptions($oauthOptions);
93  }
94  }
setOptions(array $options)
Definition: Config.php:181

Member Function Documentation

◆ __call()

__call (   $method,
array  $args 
)

Simple Proxy to the current Zend_Oauth_Config method. It's that instance which holds all configuration methods and values this object also presents as it's API.

Parameters
string$method
array$args
Returns
mixed
Exceptions
Zend_Oauth_Exceptionif method does not exist in config object

Definition at line 321 of file Client.php.

322  {
323  if (!method_exists($this->_config, $method)) {
324  #require_once 'Zend/Oauth/Exception.php';
325  throw new Zend_Oauth_Exception('Method does not exist: ' . $method);
326  }
327  return call_user_func_array(array($this->_config,$method), $args);
328  }

◆ _getSignableParametersAsQueryString()

_getSignableParametersAsQueryString ( )
protected

Collect all signable parameters into a single array across query string and POST body. Don't include POST parameters if content type is multipart POST.

Returns
array

Definition at line 299 of file Client.php.

300  {
301  $params = array();
302  if (!empty($this->paramsGet)) {
303  $params = array_merge($params, $this->paramsGet);
304  }
305  if ($this->enctype != self::ENC_FORMDATA && !empty($this->paramsPost)) {
306  $params = array_merge($params, $this->paramsPost);
307  }
308  return $params;
309  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ _prepareBody()

_prepareBody ( )
protected

Prepare the request body (for POST and PUT requests)

Returns
string
Exceptions
Zend_Http_Client_Exception

Definition at line 143 of file Client.php.

144  {
145  if($this->_streamingRequest) {
146  $this->setHeaders(self::CONTENT_LENGTH,
147  $this->raw_post_data->getTotalSize());
148  return $this->raw_post_data;
149  }
150  else {
151  return parent::_prepareBody();
152  }
153  }
setHeaders($name, $value=null)
Definition: Client.php:433

◆ getStreamingRequest()

getStreamingRequest ( )

Check whether the client is set to perform streaming requests.

Returns
boolean True if yes, false otherwise.

Definition at line 128 of file Client.php.

129  {
130  if ($this->_streamingRequest) {
131  return true;
132  } else {
133  return false;
134  }
135  }

◆ prepareOauth()

prepareOauth ( )

Performs OAuth preparation on the request before sending.

This primarily means taking a request, correctly encoding and signing all parameters, and applying the correct OAuth scheme to the method being used.

Returns
void
Exceptions
Zend_Oauth_ExceptionIf POSTBODY scheme requested, but GET request method used; or if invalid request scheme provided

Definition at line 236 of file Client.php.

237  {
238  $requestScheme = $this->getRequestScheme();
239  $requestMethod = $this->getRequestMethod();
240  $query = null;
241  if ($requestScheme == Zend_Oauth::REQUEST_SCHEME_HEADER) {
242  $oauthHeaderValue = $this->getToken()->toHeader(
243  $this->getUri(true),
244  $this->_config,
246  $this->getRealm()
247  );
248  $this->setHeaders('Authorization', $oauthHeaderValue);
249  } elseif ($requestScheme == Zend_Oauth::REQUEST_SCHEME_POSTBODY) {
250  if ($requestMethod == self::GET) {
251  #require_once 'Zend/Oauth/Exception.php';
252  throw new Zend_Oauth_Exception(
253  'The client is configured to'
254  . ' pass OAuth parameters through a POST body but request method'
255  . ' is set to GET'
256  );
257  }
258  $raw = $this->getToken()->toQueryString(
259  $this->getUri(true),
260  $this->_config,
262  );
263  $this->setRawData($raw, 'application/x-www-form-urlencoded');
264  $this->paramsPost = array();
265  } elseif ($requestScheme == Zend_Oauth::REQUEST_SCHEME_QUERYSTRING) {
267  $query = $this->getUri()->getQuery();
268  if ($query) {
269  $queryParts = explode('&', $this->getUri()->getQuery());
270  foreach ($queryParts as $queryPart) {
271  $kvTuple = explode('=', $queryPart);
272  $params[urldecode($kvTuple[0])] =
273  (array_key_exists(1, $kvTuple) ? urldecode($kvTuple[1]) : null);
274  }
275  }
276  if (!empty($this->paramsPost)) {
277  $params = array_merge($params, $this->paramsPost);
278  $query = $this->getToken()->toQueryString(
279  $this->getUri(true), $this->_config, $params
280  );
281  }
282  $query = $this->getToken()->toQueryString(
283  $this->getUri(true), $this->_config, $params
284  );
285  $this->getUri()->setQuery($query);
286  $this->paramsGet = array();
287  } else {
288  #require_once 'Zend/Oauth/Exception.php';
289  throw new Zend_Oauth_Exception('Invalid request scheme: ' . $requestScheme);
290  }
291  }
getUri($as_string=false)
Definition: Client.php:342
const REQUEST_SCHEME_HEADER
Definition: Oauth.php:33
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
setHeaders($name, $value=null)
Definition: Client.php:433
setRawData($data, $enctype=null)
Definition: Client.php:809
const REQUEST_SCHEME_QUERYSTRING
Definition: Oauth.php:35
_getSignableParametersAsQueryString()
Definition: Client.php:299
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
const REQUEST_SCHEME_POSTBODY
Definition: Oauth.php:34

◆ request()

request (   $method = null)

Same as Zend_Http_Client::request() except just before the request is executed, we automatically append any necessary OAuth parameters and sign the request using the relevant signature method.

Parameters
string$method
Returns
Zend_Http_Response

Definition at line 217 of file Client.php.

218  {
219  if ($method !== null) {
220  $this->setMethod($method);
221  }
222  $this->prepareOauth();
223  return parent::request();
224  }
setMethod($method=self::GET)
Definition: Client.php:191

◆ resetParameters()

resetParameters (   $clearAll = false)

Clear all custom parameters we set.

Returns
Zend_Http_Client

Definition at line 160 of file Client.php.

161  {
162  $this->_streamingRequest = false;
163  return parent::resetParameters($clearAll);
164  }

◆ setAdapter()

setAdapter (   $adapter)

Load the connection adapter

Parameters
Zend_Http_Client_Adapter_Interface$adapter
Returns
void

Definition at line 102 of file Client.php.

103  {
104  if ($adapter == null) {
105  $this->adapter = $adapter;
106  } else {
107  parent::setAdapter($adapter);
108  }
109  }

◆ setMethod()

setMethod (   $method = self::GET)

Same as Zend_Http_Client::setMethod() except it also creates an Oauth specific reference to the method type. Might be defunct and removed in a later iteration.

Parameters
string$method
Returns
Zend_Http_Client

Definition at line 191 of file Client.php.

192  {
193  if ($method == self::GET) {
194  $this->setRequestMethod(self::GET);
195  } elseif($method == self::POST) {
196  $this->setRequestMethod(self::POST);
197  } elseif($method == self::PUT) {
198  $this->setRequestMethod(self::PUT);
199  } elseif($method == self::DELETE) {
200  $this->setRequestMethod(self::DELETE);
201  } elseif($method == self::HEAD) {
202  $this->setRequestMethod(self::HEAD);
203  } elseif($method == self::OPTIONS) {
204  $this->setRequestMethod(self::OPTIONS);
205  }
206  return parent::setMethod($method);
207  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ setRawDataStream()

setRawDataStream (   $data,
  $enctype = null 
)

Set the raw (already encoded) POST data from a stream source.

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().

Parameters
string$dataThe request data
string$enctypeThe encoding type
Returns
Zend_Http_Client

Definition at line 177 of file Client.php.

178  {
179  $this->_streamingRequest = true;
180  return $this->setRawData($data, $enctype);
181  }
setRawData($data, $enctype=null)
Definition: Client.php:809

◆ setStreamingRequest()

setStreamingRequest (   $value)

Set the streamingRequest variable which controls whether we are sending the raw (already encoded) POST data from a stream source.

Parameters
boolean$valueThe value to set.
Returns
void

Definition at line 118 of file Client.php.

119  {
120  $this->_streamingRequest = $value;
121  }
$value
Definition: gender.phtml:16

Field Documentation

◆ $_config

$_config = null
protected

Definition at line 56 of file Client.php.

◆ $_streamingRequest

$_streamingRequest = null
protected

Definition at line 64 of file Client.php.

◆ $supportsRevisionA

$supportsRevisionA = false
static

Flag to indicate that the client has detected the server as supporting OAuth 1.0a

Definition at line 46 of file Client.php.


The documentation for this class was generated from the following file: