File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
modules/swagger-codegen/src/main/resources/php Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,11 @@ class ApiClient
153153 if ($this->config->getCurlTimeout() !== 0) {
154154 curl_setopt($curl , CURLOPT_TIMEOUT, $this -> config -> getCurlTimeout ());
155155 }
156+ // set connect timeout, if needed
157+ if ($this->config->getCurlConnectTimeout() != 0) {
158+ curl_setopt($curl , CURLOPT_CONNECTTIMEOUT, $this -> config -> getCurlConnectTimeout ());
159+ }
160+
156161 // return the result on success, rather than just true
157162 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
158163
Original file line number Diff line number Diff line change @@ -87,6 +87,13 @@ class Configuration
8787 */
8888 protected $curlTimeout = 0;
8989
90+ /**
91+ * Timeout (second) of the HTTP connection, by default set to 0, no timeout
92+ *
93+ * @var string
94+ */
95+ protected $curlConnectTimeout = 0;
96+
9097 /**
9198 * User agent of the HTTP request, set to " PHP-Swagger" by default
9299 *
@@ -370,6 +377,33 @@ class Configuration
370377 return $this -> curlTimeout ;
371378 }
372379
380+ /**
381+ * Sets the HTTP connect timeout value
382+ *
383+ * @param integer $seconds Number of seconds before connection times out [set to 0 for no timeout]
384+ *
385+ * @return Configuration
386+ */
387+ public function setCurlConnectTimeout($seconds)
388+ {
389+ if (! is_numeric($seconds ) || $seconds < 0) {
390+ throw new \InvalidArgumentException(' Connect timeout value must be numeric and a non-negative number.' );
391+ }
392+
393+ $this->curlConnectTimeout = $seconds;
394+ return $this;
395+ }
396+
397+ /**
398+ * Gets the HTTP connect timeout value
399+ *
400+ * @return string HTTP connect timeout value
401+ */
402+ public function getCurlConnectTimeout()
403+ {
404+ return $this -> curlConnectTimeout ;
405+ }
406+
373407 /**
374408 * Sets debug flag
375409 *
You can’t perform that action at this time.
0 commit comments