diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index dd1a221d766..8f0f1167151 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -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); diff --git a/modules/swagger-codegen/src/main/resources/php/configuration.mustache b/modules/swagger-codegen/src/main/resources/php/configuration.mustache index 4e10f33823c..edd0f76bf55 100644 --- a/modules/swagger-codegen/src/main/resources/php/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/php/configuration.mustache @@ -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 diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index b8add9f133c..ce025591447 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -167,7 +167,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header 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 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header $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); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php index 17e0a6feda3..d85d33af051 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php @@ -177,6 +177,13 @@ class Configuration */ protected $proxyPassword; + /** + * Allow Curl encoding header + * + * @var bool + */ + protected $allowEncoding = false; + /** * Constructor */ @@ -445,6 +452,16 @@ public function setCurlConnectTimeout($seconds) 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 @@ public function getCurlConnectTimeout() return $this->curlConnectTimeout; } + /** + * Get whether to allow encoding + * + * @return bool + */ + public function getAllowEncoding() + { + return $this->allowEncoding; + } /** * Sets the HTTP Proxy Host