|
|
@@ -100,11 +100,11 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
|
|
|
/**
|
|
|
* Stream for storing output
|
|
|
- *
|
|
|
+ *
|
|
|
* @var resource
|
|
|
*/
|
|
|
protected $out_stream;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Adapter constructor
|
|
|
*
|
|
|
@@ -163,15 +163,15 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Retrieve the array of all configuration options
|
|
|
- *
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getConfig()
|
|
|
- {
|
|
|
- return $this->_config;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * Retrieve the array of all configuration options
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getConfig()
|
|
|
+ {
|
|
|
+ return $this->_config;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Direct setter for cURL adapter related options.
|
|
|
@@ -258,7 +258,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
* @return string $request
|
|
|
* @throws Zend_Http_Client_Adapter_Exception If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option
|
|
|
*/
|
|
|
- public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
|
|
|
+ public function write($method, $uri, $httpVersion = '1.1', $headers = array(), $body = '')
|
|
|
{
|
|
|
// Make sure we're properly connected
|
|
|
if (!$this->_curl) {
|
|
|
@@ -302,16 +302,16 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
unset($headers[$k]);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) {
|
|
|
require_once 'Zend/Http/Client/Adapter/Exception.php';
|
|
|
throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(is_resource($body)) {
|
|
|
$body = '';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$curlMethod = CURLOPT_PUT;
|
|
|
} else {
|
|
|
$curlMethod = CURLOPT_CUSTOMREQUEST;
|
|
|
@@ -344,9 +344,9 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
require_once 'Zend/Http/Client/Adapter/Exception.php';
|
|
|
throw new Zend_Http_Client_Adapter_Exception("Streaming requests are allowed only with PUT");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// get http version to use
|
|
|
- $curlHttp = ($http_ver = 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
|
|
|
+ $curlHttp = ($httpVersion == '1.1') ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
|
|
|
|
|
|
// mark as HTTP request and set HTTP method
|
|
|
curl_setopt($this->_curl, $curlHttp, true);
|
|
|
@@ -357,7 +357,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
curl_setopt($this->_curl, CURLOPT_HEADER, false);
|
|
|
curl_setopt($this->_curl, CURLOPT_HEADERFUNCTION, array($this, "readHeader"));
|
|
|
// and data will be written into the file
|
|
|
- curl_setopt($this->_curl, CURLOPT_FILE, $this->out_stream);
|
|
|
+ curl_setopt($this->_curl, CURLOPT_FILE, $this->out_stream);
|
|
|
} else {
|
|
|
// ensure headers are also returned
|
|
|
curl_setopt($this->_curl, CURLOPT_HEADER, true);
|
|
|
@@ -403,7 +403,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
|
|
|
// send the request
|
|
|
$response = curl_exec($this->_curl);
|
|
|
-
|
|
|
+
|
|
|
// if we used streaming, headers are already there
|
|
|
if(!is_resource($this->out_stream)) {
|
|
|
$this->_response = $response;
|
|
|
@@ -476,19 +476,19 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
|
|
|
|
|
|
/**
|
|
|
* Set output stream for the response
|
|
|
- *
|
|
|
+ *
|
|
|
* @param resource $stream
|
|
|
* @return Zend_Http_Client_Adapter_Socket
|
|
|
*/
|
|
|
- public function setOutputStream($stream)
|
|
|
+ public function setOutputStream($stream)
|
|
|
{
|
|
|
$this->out_stream = $stream;
|
|
|
return $this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Header reader function for CURL
|
|
|
- *
|
|
|
+ *
|
|
|
* @param resource $curl
|
|
|
* @param string $header
|
|
|
* @return int
|