Commit 33a16826 authored by DrZippie's avatar DrZippie

Authentication with Curl and Http Adapter

$config = array(
	'adapteroptions' =>
		array ('host' =>  '127.0.0.1', 'username' => 'user', 'password' =>
			'pass', 'port' => '8983'
		)
	);
$client = new \Solarium_Client(  $config );
// $client->setAdapter('Solarium_Client_Adapter_Curl');
parent 7b57f3e2
......@@ -138,6 +138,11 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$options['headers']['Content-Type'] = 'text/xml; charset=utf-8';
}
if ( isset( $this->_options['username']) && isset( $this->_options['password'])) {
curl_setopt($handler, CURLOPT_USERPWD, $this->_options['username']. ':' . $this->_options['password'] );
curl_setopt($handler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
if (count($options['headers'])) {
$headers = array();
foreach ($options['headers'] as $key => $value) {
......
......@@ -121,6 +121,12 @@ class Solarium_Client_Adapter_Http extends Solarium_Client_Adapter
);
}
if ( isset( $this->_options['username']) && isset( $this->_options['password'])) {
$request->addHeader('Authorization: Basic ' . base64_encode($this->_options['username']. ':' . $this->_options['password'] ));
}
return $context;
}
......
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