Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ class ApiClient
if ($this->config->getCurlTimeout() !== 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
}
// set connect timeout, if needed
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ class Configuration
*/
protected $curlTimeout = 0;

/**
* Timeout (second) of the HTTP connection, by default set to 0, no timeout
*
* @var string
*/
protected $curlConnectTimeout = 0;

/**
* User agent of the HTTP request, set to "PHP-Swagger" by default
*
Expand Down Expand Up @@ -370,6 +377,33 @@ class Configuration
return $this->curlTimeout;
}

/**
* Sets the HTTP connect timeout value
*
* @param integer $seconds Number of seconds before connection times out [set to 0 for no timeout]
*
* @return Configuration
*/
public function setCurlConnectTimeout($seconds)
{
if (!is_numeric($seconds) || $seconds < 0) {
throw new \InvalidArgumentException('Connect timeout value must be numeric and a non-negative number.');
}

$this->curlConnectTimeout = $seconds;
return $this;
}

/**
* Gets the HTTP connect timeout value
*
* @return string HTTP connect timeout value
*/
public function getCurlConnectTimeout()
{
return $this->curlConnectTimeout;
}

/**
* Sets debug flag
*
Expand Down