Commit 294a11d0 authored by Gasol Wu's avatar Gasol Wu

Merge branch 'pecl_support' into mlt_support

parents e4ec42e4 8f1962aa
...@@ -65,12 +65,12 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter ...@@ -65,12 +65,12 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter
{ {
$uri = $this->getBaseUri() . $request->getUri(); $uri = $this->getBaseUri() . $request->getUri();
$method = $request->getMethod(); $method = $request->getMethod();
$options = array( $options = $this->_createOptions($request);
'timeout' => $this->getTimeout()
);
if ($method == Solarium_Client_Request::METHOD_POST) { if ($method == Solarium_Client_Request::METHOD_POST) {
$options['headers']['Content-Type'] = 'text/xml; charset=utf-8'; if (!isset($options['headers']['Content-Type'])) {
$options['headers']['Content-Type'] = 'text/xml; charset=utf-8';
}
$httpResponse = http_post_data($uri, $request->getRawData(), $options); $httpResponse = http_post_data($uri, $request->getRawData(), $options);
} else if ($method == Solarium_Client_Request::METHOD_GET) { } else if ($method == Solarium_Client_Request::METHOD_GET) {
$httpResponse = http_get($uri, $options); $httpResponse = http_get($uri, $options);
...@@ -93,6 +93,28 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter ...@@ -93,6 +93,28 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter
return array($data, $headers); return array($data, $headers);
} }
/**
* Create http request options from request.
*
* @link http://php.net/manual/en/http.request.options.php
*
* @param Solarium_Client_Request $request
* @return array
*/
protected function _createOptions($request)
{
$options = array(
'timeout' => $this->getTimeout()
);
foreach ($request->getHeaders() as $headerLine) {
list($header, $value) = explode(':', $headerLine);
if (!$header = trim($header)) {
$options['headers'][$header] = trim($value);
}
}
return $options;
}
/** /**
* Check result of a request * Check result of a request
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment