diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 6cd00a689f97c5dde828ecb3c6f6fef3acbff17d..ee34534db38b092575efb32323950612f6a859f4 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -553,6 +553,11 @@ url = https://www.myendnoteweb.com/EndNoteWeb.html ;host = your.proxy.server ;port = 8000 +; Default HTTP settings can be loaded here. These values will be passed to +; the \Zend\Http\Client's setOptions method. +[Http] +;sslcapath = "/etc/ssl/certs" + ; Spelling Suggestions ; ; Note: These settings affect the VuFind side of spelling suggestions; you diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 846c537fbca9c03afde30b4cd4e106e8edbde41e..20a5ff76e25b0003c214fd74c9a78aa62e37156d 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -187,7 +187,9 @@ $config = array( $options['proxy_port'] = $config->Proxy->port; } } - return new \VuFindHttp\HttpService($options); + $defaults = isset($config->Http) + ? $config->Http->toArray() : array(); + return new \VuFindHttp\HttpService($options, $defaults); }, 'VuFind\HMAC' => function ($sm) { return new \VuFind\Crypt\HMAC( diff --git a/module/VuFindHttp/src/VuFindHttp/HttpService.php b/module/VuFindHttp/src/VuFindHttp/HttpService.php index 1a71f5695ffea3dd10967073204b727b6f5b6ac3..ce027a100a7c74454c68a6284723df76524ef1d1 100644 --- a/module/VuFindHttp/src/VuFindHttp/HttpService.php +++ b/module/VuFindHttp/src/VuFindHttp/HttpService.php @@ -40,7 +40,6 @@ namespace VuFindHttp; */ class HttpService implements HttpServiceInterface { - /** * Regular expression matching a request to localhost. * @@ -57,6 +56,13 @@ class HttpService implements HttpServiceInterface */ protected $proxyConfig; + /** + * Default client options. + * + * @var array + */ + protected $defaults; + /** * Default adapter * @@ -68,12 +74,15 @@ class HttpService implements HttpServiceInterface * Constructor. * * @param array $proxyConfig Proxy configuration + * @param array $defaults Default HTTP options * * @return void */ - public function __construct (array $proxyConfig = array()) - { + public function __construct (array $proxyConfig = array(), + array $defaults = array() + ) { $this->proxyConfig = $proxyConfig; + $this->defaults = $defaults; } /** @@ -188,6 +197,9 @@ class HttpService implements HttpServiceInterface ) { $client = new \Zend\Http\Client(); $client->setMethod($method); + if (!empty($this->defaults)) { + $client->setOptions($this->defaults); + } if (null !== $this->defaultAdapter) { $client->setAdapter($this->defaultAdapter); }