diff --git a/modules/swagger-codegen/src/main/resources/php/Swagger.mustache b/modules/swagger-codegen/src/main/resources/php/Swagger.mustache index f8a602963b6..1aace837b1d 100644 --- a/modules/swagger-codegen/src/main/resources/php/Swagger.mustache +++ b/modules/swagger-codegen/src/main/resources/php/Swagger.mustache @@ -37,6 +37,16 @@ class APIClient { $this->apiServer = $apiServer; } + /** + * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] + */ + public function setTimeout($seconds) { + if (!is_numeric($seconds)) { + throw new Exception('Timeout variable must be numeric.'); + } + $this->curl_timout = $seconds; + } + /** * @param string $resourcePath path to method endpoint @@ -72,7 +82,9 @@ class APIClient { $url = $this->apiServer . $resourcePath; $curl = curl_init(); - curl_setopt($curl, CURLOPT_TIMEOUT, 5); + if ($this->curl_timout) { + curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout); + } // return the result on success, rather than just TRUE curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);