diff --git a/S3.php b/S3.php index 83c01733..6a481be4 100644 --- a/S3.php +++ b/S3.php @@ -2025,13 +2025,15 @@ final class S3Request * @param string $endpoint AWS endpoint URI * @return mixed */ - function __construct($verb, $bucket = '', $uri = '', $endpoint = 's3.amazonaws.com') + function __construct($verb, $bucket = '', $uri = '', $endpoint = 's3.amazonaws.com', $connTimeout = 30, $execTimeout = 30) { $this->endpoint = $endpoint; $this->verb = $verb; $this->bucket = $bucket; $this->uri = $uri !== '' ? '/'.str_replace('%2F', '/', rawurlencode($uri)) : '/'; + $this->connTimeout = $connTimeout; + $this->execTimeout = $execTimeout; //if ($this->bucket !== '') // $this->resource = '/'.$this->bucket.$this->uri; @@ -2164,6 +2166,10 @@ public function getResponse() curl_setopt($curl, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', S3::$proxy['user'], S3::$proxy['pass'])); } + // Timeouts + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->connTimeout); + curl_setopt($curl, CURLOPT_TIMEOUT, $this->execTimeout); + // Headers $headers = array(); $amz = array(); foreach ($this->amzHeaders as $header => $value)