diff --git a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php index a1d7a4a2fdbe2a3bebf3ccbb4e910149662dbc8a..7385d8dfa344fa8a107fffb92e6b22bf19bd1254 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php +++ b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php @@ -27,7 +27,7 @@ * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ namespace VuFind\ILS\Driver; -use VuFind\Exception\ILS as ILSException, VuFind\Http\Client as HttpClient; +use VuFind\Exception\ILS as ILSException; /** * Horizon ILS Driver (w/ XML API support) @@ -39,8 +39,27 @@ use VuFind\Exception\ILS as ILSException, VuFind\Http\Client as HttpClient; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class HorizonXMLAPI extends Horizon +class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInterface { + /** + * HTTP service + * + * @var \VuFindHttp\HttpServiceInterface + */ + protected $httpService = null; + + /** + * Set the HTTP service to be used for HTTP requests. + * + * @param HttpServiceInterface $service HTTP service + * + * @return void + */ + public function setHttpService(\VuFindHttp\HttpServiceInterface $service) + { + $this->httpService = $service; + } + /** * Initialize the driver. * @@ -251,11 +270,10 @@ class HorizonXMLAPI extends Horizon $urlParams .= "?" . implode("&", $queryString); // Create Proxy Request - $client = new HttpClient(); - $client->setUri($urlParams); + $client = $this->httpService->createClient($urlParams, $mode); // Send Request and Retrieve Response - $result = $client->setMethod($mode)->send(); + $result = $client->send(); if (!$result->isSuccess()) { throw new ILSException('Problem with XML API.'); } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php index 54a487eb0021bc3ee91181d7bffe0f29736c1d09..e673e0b0e6f73771732890cbc7368a9bf5da646a 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php @@ -26,8 +26,7 @@ * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ namespace VuFind\ILS\Driver; -use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, - VuFind\Http\Client as HttpClient; +use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException; /** * VuFind Connector for Innovative @@ -41,8 +40,28 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Innovative extends AbstractBase +class Innovative extends AbstractBase implements + \VuFindHttp\HttpServiceAwareInterface { + /** + * HTTP service + * + * @var \VuFindHttp\HttpServiceInterface + */ + protected $httpService = null; + + /** + * Set the HTTP service to be used for HTTP requests. + * + * @param HttpServiceInterface $service HTTP service + * + * @return void + */ + public function setHttpService(\VuFindHttp\HttpServiceInterface $service) + { + $this->httpService = $service; + } + /** * Initialize the driver. * @@ -70,9 +89,7 @@ class Innovative extends AbstractBase { // Make the NCIP request: try { - $client = new HttpClient(); - $client->setUri($url); - $result = $client->setMethod('GET')->send(); + $result = $this->httpService->get($url); } catch (\Exception $e) { throw new ILSException($e->getMessage()); } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php index 327e23964068af023266c3c641c6efa416b39ed0..cef96caabb73c45008350c6dc26272db75708fdc 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php @@ -26,7 +26,7 @@ */ namespace VuFind\ILS\Driver; use File_MARC, VuFind\Config\Reader as ConfigReader, - VuFind\Exception\ILS as ILSException, VuFind\Http\Client as HttpClient; + VuFind\Exception\ILS as ILSException; /** * SirsiDynix Unicorn ILS Driver (VuFind side) @@ -43,7 +43,7 @@ use File_MARC, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://code.google.com/p/vufind-unicorn/ vufind-unicorn project **/ -class Unicorn extends AbstractBase +class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface { protected $host; protected $port; @@ -52,6 +52,25 @@ class Unicorn extends AbstractBase protected $db; + /** + * HTTP service + * + * @var \VuFindHttp\HttpServiceInterface + */ + protected $httpService = null; + + /** + * Set the HTTP service to be used for HTTP requests. + * + * @param HttpServiceInterface $service HTTP service + * + * @return void + */ + public function setHttpService(\VuFindHttp\HttpServiceInterface $service) + { + $this->httpService = $service; + } + /** * Initialize the driver. * @@ -1144,9 +1163,7 @@ class Unicorn extends AbstractBase } } - $httpClient = new HttpClient(); - $httpClient->setMethod('POST'); - $httpClient->setUri($url); + $httpClient = $this->httpService->createClient($url, 'POST'); $httpClient->setRawBody(http_build_query($params)); $httpClient->setEncType('application/x-www-form-urlencoded'); // use HTTP POST so parameters like user id and PIN are NOT logged by web diff --git a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php index d4f01500a8b6d307eb5f619e02a8d30da7ac9778..e54a7d49364f07fb99e4a527861278a3f2b79ef2 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php @@ -26,8 +26,7 @@ * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ namespace VuFind\ILS\Driver; -use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, - VuFind\Http\Client as HttpClient; +use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException; /** * VTLS Virtua Driver @@ -38,10 +37,34 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Virtua extends AbstractBase +class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface { + /** + * Oracle connection + * + * @var \VuFind\Connection\Oracle + */ protected $db; + /** + * HTTP service + * + * @var \VuFindHttp\HttpServiceInterface + */ + protected $httpService = null; + + /** + * Set the HTTP service to be used for HTTP requests. + * + * @param HttpServiceInterface $service HTTP service + * + * @return void + */ + public function setHttpService(\VuFindHttp\HttpServiceInterface $service) + { + $this->httpService = $service; + } + /** * Initialize the driver. * @@ -1856,8 +1879,7 @@ class Virtua extends AbstractBase $method = (is_null($postParams) && is_null($rawPost)) ? 'GET' : 'POST'; try { - $client = new HttpClient(); - $client->setUri($url); + $client = $this->httpService->createClient($url); if (is_array($postParams)) { $client->setParameterPost($postParams); } diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php index 98710a053dc936d0c90164c133654ee74b4eddd4..2c889c7613f4cc46ecdc9e9adf2011dde090a6aa 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php +++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php @@ -29,9 +29,7 @@ */ namespace VuFind\ILS\Driver; use PDOException, VuFind\Exception\Date as DateException, - VuFind\Exception\ILS as ILSException, - VuFind\Http\Client as HttpClient, - VuFind\ILS\Connection as ILSConnection; + VuFind\Exception\ILS as ILSException, VuFind\ILS\Connection as ILSConnection; /** * Voyager Restful ILS Driver @@ -44,7 +42,7 @@ use PDOException, VuFind\Exception\Date as DateException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class VoyagerRestful extends Voyager +class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInterface { protected $ws_host; protected $ws_port; @@ -56,6 +54,25 @@ class VoyagerRestful extends Voyager protected $holdCheckLimit; protected $checkRenewalsUpFront; + /** + * HTTP service + * + * @var \VuFindHttp\HttpServiceInterface + */ + protected $httpService = null; + + /** + * Set the HTTP service to be used for HTTP requests. + * + * @param HttpServiceInterface $service HTTP service + * + * @return void + */ + public function setHttpService(\VuFindHttp\HttpServiceInterface $service) + { + $this->httpService = $service; + } + /** * Initialize the driver. * @@ -453,8 +470,7 @@ class VoyagerRestful extends Voyager $urlParams .= "?" . implode("&", $queryString); // Create Proxy Request - $client = new HttpClient(); - $client->setUri($urlParams); + $client = $this->httpService->createClient($urlParams); // Attach XML if necessary if ($xml !== false) { diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php index ac200667b24fdc31ccec6a2afdcfaa010616d87a..3f2599bde0b4067f3c5aa3281ca6e25271bad955 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php +++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php @@ -26,8 +26,7 @@ * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ namespace VuFind\ILS\Driver; -use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, - VuFind\Http\Client as HttpClient; +use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException; /** * XC NCIP Toolkit ILS Driver @@ -38,8 +37,27 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class XCNCIP extends AbstractBase +class XCNCIP extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface { + /** + * HTTP service + * + * @var \VuFindHttp\HttpServiceInterface + */ + protected $httpService = null; + + /** + * Set the HTTP service to be used for HTTP requests. + * + * @param HttpServiceInterface $service HTTP service + * + * @return void + */ + public function setHttpService(\VuFindHttp\HttpServiceInterface $service) + { + $this->httpService = $service; + } + /** * Initialize the driver. * @@ -67,8 +85,8 @@ class XCNCIP extends AbstractBase { // Make the NCIP request: try { - $client = new HttpClient(); - $client->setUri($this->config['Catalog']['url']); + $client = $this->httpService + ->createClient($this->config['Catalog']['url']); $client->setParameterPost(array('NCIP' => $xml)); $result = $client->setMethod('POST')->send(); } catch (\Exception $e) { diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php index 9eab35a6ee3504a71f6d4a75bebc58c7d3ad5131..13518c9907f1ee9af75fe74a3b11b325631adfee 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php +++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php @@ -26,8 +26,7 @@ * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ namespace VuFind\ILS\Driver; -use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, - VuFind\Http\Client as HttpClient; +use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException; /** * XC NCIP Toolkit (v2) ILS Driver @@ -38,8 +37,27 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class XCNCIP2 extends AbstractBase +class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface { + /** + * HTTP service + * + * @var \VuFindHttp\HttpServiceInterface + */ + protected $httpService = null; + + /** + * Set the HTTP service to be used for HTTP requests. + * + * @param HttpServiceInterface $service HTTP service + * + * @return void + */ + public function setHttpService(\VuFindHttp\HttpServiceInterface $service) + { + $this->httpService = $service; + } + /** * Initialize the driver. * @@ -67,8 +85,8 @@ class XCNCIP2 extends AbstractBase { // Make the NCIP request: try { - $client = new HttpClient(); - $client->setUri($this->config['Catalog']['url']); + $client = $this->httpService + ->createClient($this->config['Catalog']['url']); $client->setRawBody($xml); $client->setEncType('application/xml; "charset=utf-8"'); $result = $client->setMethod('POST')->send();