Просмотр исходного кода

Merge branch 'hotfix/597'

Close #597
Fixes #582
Matthew Weier O'Phinney 10 лет назад
Родитель
Сommit
5356b454d1
1 измененных файлов с 16 добавлено и 9 удалено
  1. 16 9
      library/Zend/Http/Client/Adapter/Curl.php

+ 16 - 9
library/Zend/Http/Client/Adapter/Curl.php

@@ -221,17 +221,24 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
             curl_setopt($this->_curl, CURLOPT_PORT, intval($port));
         }
 
-        // Set timeout
+        // Set connection timeout
+        $connectTimeout  = $this->config['timeout'];
+        $constant        = CURLOPT_CONNECTTIMEOUT;
         if (defined('CURLOPT_CONNECTTIMEOUT_MS')) {
-            curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT_MS, $this->_config['timeout'] * 1000);
-        } else {
-            curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $this->_config['timeout']);
+            $connectTimeout *= 1000;
+            $constant = constant('CURLOPT_CONNECTTIMEOUT_MS');
         }
-
-        if (defined('CURLOPT_TIMEOUT_MS')) {
-            curl_setopt($this->_curl, CURLOPT_TIMEOUT_MS, $this->_config['timeout'] * 1000);
-        } else {
-            curl_setopt($this->_curl, CURLOPT_TIMEOUT, $this->_config['timeout']);
+        curl_setopt($this->_curl, $constant, $connectTimeout);
+
+        // Set request timeout (once connection is established)
+        if (array_key_exists('request_timeout', $this->_config)) {
+            $requestTimeout  = $this->config['request_timeout'];
+            $constant        = CURLOPT_TIMEOUT;
+            if (defined('CURLOPT_TIMEOUT_MS')) {
+                $requestTimeout *= 1000;
+                $constant = constant('CURLOPT_TIMEOUT_MS');
+            }
+            curl_setopt($this->_curl, $constant, $requestTimeout);
         }
 
         // Set Max redirects