ソースを参照

[Http] Rationalize timeout for curl according to others adapters

Eric GELOEN 11 年 前
コミット
8cf3e55cba
1 ファイル変更11 行追加1 行削除
  1. 11 1
      library/Zend/Http/Client/Adapter/Curl.php

+ 11 - 1
library/Zend/Http/Client/Adapter/Curl.php

@@ -222,7 +222,17 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
         }
 
         // Set timeout
-        curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $this->_config['timeout']);
+        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']);
+        }
+
+        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']);
+        }
 
         // Set Max redirects
         curl_setopt($this->_curl, CURLOPT_MAXREDIRS, $this->_config['maxredirects']);