From 5d9c40ba4013cd6af72e81dda763cb236b067db0 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 19 Jul 2013 10:12:36 -0400 Subject: [PATCH] Created mechanism for setting up SSL and other HTTP options. Resolves VUFIND-853. --- config/vufind/config.ini | 5 +++++ module/VuFind/config/module.config.php | 4 +++- .../VuFindHttp/src/VuFindHttp/HttpService.php | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 6cd00a689f9..ee34534db38 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 846c537fbca..20a5ff76e25 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 1a71f5695ff..ce027a100a7 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); } -- GitLab