issue #3365 adding accept encoding for PHP (#5525)

This commit is contained in:
mguan-trulia
2017-05-05 19:40:08 -07:00
committed by wing328
parent 9212c21567
commit 918343b684
4 changed files with 62 additions and 2 deletions

View File

@@ -157,7 +157,7 @@ class ApiClient
if ($this->config->getCurlConnectTimeout() != 0) {
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->config->getCurlConnectTimeout());
}
// return the result on success, rather than just true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -189,6 +189,10 @@ class ApiClient
$url = ($url . '?' . http_build_query($queryParams));
}
if ($this->config->getAllowEncoding()) {
curl_setopt($curl, CURLOPT_ENCODING, '');
}
if ($method === self::$POST) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);

View File

@@ -167,6 +167,13 @@ class Configuration
*/
protected $proxyPassword;
/**
* Allow Curl encoding header
*
* @var bool
*/
protected $allowEncoding = false;
/**
* Constructor
*/
@@ -435,6 +442,16 @@ class Configuration
return $this;
}
/**
* Set whether to accept encoding
* @param bool $allowEncoding
*/
public function setAllowEncoding($allowEncoding)
{
$this->allowEncoding = $allowEncoding;
return $this;
}
/**
* Gets the HTTP connect timeout value
*
@@ -445,6 +462,15 @@ class Configuration
return $this->curlConnectTimeout;
}
/**
* Get whether to allow encoding
*
* @return bool
*/
public function getAllowEncoding()
{
return $this->allowEncoding;
}
/**
* Sets the HTTP Proxy Host

View File

@@ -167,7 +167,7 @@ class ApiClient
if ($this->config->getCurlConnectTimeout() != 0) {
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->config->getCurlConnectTimeout());
}
// return the result on success, rather than just true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -199,6 +199,10 @@ class ApiClient
$url = ($url . '?' . http_build_query($queryParams));
}
if ($this->config->getAllowEncoding()) {
curl_setopt($curl, CURLOPT_ENCODING, '');
}
if ($method === self::$POST) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);

View File

@@ -177,6 +177,13 @@ class Configuration
*/
protected $proxyPassword;
/**
* Allow Curl encoding header
*
* @var bool
*/
protected $allowEncoding = false;
/**
* Constructor
*/
@@ -445,6 +452,16 @@ class Configuration
return $this;
}
/**
* Set whether to accept encoding
* @param bool $allowEncoding
*/
public function setAllowEncoding($allowEncoding)
{
$this->allowEncoding = $allowEncoding;
return $this;
}
/**
* Gets the HTTP connect timeout value
*
@@ -455,6 +472,15 @@ class Configuration
return $this->curlConnectTimeout;
}
/**
* Get whether to allow encoding
*
* @return bool
*/
public function getAllowEncoding()
{
return $this->allowEncoding;
}
/**
* Sets the HTTP Proxy Host