Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ZendClient.php
Go to the documentation of this file.
1 <?php
12 namespace Magento\Framework\HTTP;
13 
15 {
21  protected $_urlEncodeBody = true;
22 
27  public function __construct($uri = null, $config = null)
28  {
29  $this->config['useragent'] = \Magento\Framework\HTTP\ZendClient::class;
30 
31  parent::__construct($uri, $config);
32  }
33 
37  protected function _trySetCurlAdapter()
38  {
39  if (extension_loaded('curl')) {
40  $this->setAdapter(new \Magento\Framework\HTTP\Adapter\Curl());
41  }
42  return $this;
43  }
44 
49  public function request($method = null)
50  {
51  $this->_trySetCurlAdapter();
52  return parent::request($method);
53  }
54 
61  public function setUrlEncodeBody($flag)
62  {
63  $this->_urlEncodeBody = $flag;
64  return $this;
65  }
66 
73  protected function _prepareBody()
74  {
75  $body = parent::_prepareBody();
76 
77  if (!$this->_urlEncodeBody && $body) {
78  $body = urldecode($body);
79  $this->setHeaders('Content-length', strlen($body));
80  }
81 
82  return $body;
83  }
84 }
setHeaders($name, $value=null)
Definition: Client.php:433
__construct($uri=null, $config=null)
Definition: ZendClient.php:27
setAdapter($adapter)
Definition: Client.php:923