Преглед изворни кода

[#597] Review and normalize

- Use default values; reset only if `*_MS` version of constant is present.
Matthew Weier O'Phinney пре 10 година
родитељ
комит
05432608f5
1 измењених фајлова са 14 додато и 9 уклоњено
  1. 14 9
      library/Zend/Http/Client/Adapter/Curl.php

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

@@ -221,19 +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');
         }
+        curl_setopt($this->_curl, $constant, $connectTimeout);
 
+        // Set request timeout (once connection is established)
         if (array_key_exists('request_timeout', $this->_config)) {
-          if (defined('CURLOPT_TIMEOUT_MS')) {
-              curl_setopt($this->_curl, CURLOPT_TIMEOUT_MS, $this->_config['request_timeout'] * 1000);
-          } else {
-              curl_setopt($this->_curl, CURLOPT_TIMEOUT, $this->_config['request_timeout']);
-          }
+            $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