diff --git a/library/Class/HttpClientFactory.php b/library/Class/HttpClientFactory.php index c1c436520ac0b8db363bb8ffea4f9b0084acb621..47e342845b2f72bfd032eab5be5ce106f344efb4 100644 --- a/library/Class/HttpClientFactory.php +++ b/library/Class/HttpClientFactory.php @@ -21,7 +21,12 @@ class Class_HttpClientFactory { - protected static $instance, $adapter; + protected static + $instance, + $adapter; + + protected + $_last_client; public static function getInstance() { @@ -49,7 +54,12 @@ class Class_HttpClientFactory { $client->setAdapter(static::$adapter); $client->setConfig(['timeout' => 2]); - return $client; + return $this->_last_client = $client; + } + + + public function getLastHttpClient() { + return $this->_last_client; } } diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php index c819f17ca9e15732e04920f75381145853a3b8c0..ce9be047508026b19b95db52cdb1d079b9ad90b4 100644 --- a/library/Class/WebService/SIGB/Koha/Service.php +++ b/library/Class/WebService/SIGB/Koha/Service.php @@ -239,7 +239,8 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR try { $this->getNotice(1); - $httpClient = $this->getWebClient()->getHttpClient(); + $httpClient = $this->getWebClient(); + $message = $httpClient->getLastRequest(); if ($response = $httpClient->getLastResponse()) $message .= $response->getStatus() . " " . $response->getMessage() diff --git a/library/Class/WebService/SimpleWebClient.php b/library/Class/WebService/SimpleWebClient.php index 03d8d760a12e1d14d1c88886b84c49f3225ff1ce..88ad992c0d5d7e53715fbe53402ebc1360eacffa 100644 --- a/library/Class/WebService/SimpleWebClient.php +++ b/library/Class/WebService/SimpleWebClient.php @@ -23,12 +23,15 @@ class Class_WebService_SimpleWebClient { use Trait_Singleton; + protected + $_last_http_client; + public function getHttpClient() { - return Class_HttpClientFactory::getInstance()->newHttpClient(); + return $this->_last_http_client = Class_HttpClientFactory::getInstance()->newHttpClient(); } - public function open_url($url,$options = []) { + public function open_url($url,$options = []) { $httpClient = $this->getHttpClient(); if (isset($options['headers'])) @@ -43,7 +46,6 @@ class Class_WebService_SimpleWebClient { } - public function postData($url, $params) { $httpClient = $this->getHttpClient(); $httpClient->resetParameters(); @@ -55,6 +57,20 @@ class Class_WebService_SimpleWebClient { return $httpClient->request()->getBody(); } + + + public function getLastRequest() { + return $this->_last_http_client + ? $this->_last_http_client->getLastRequest() + : null; + } + + + public function getLastResponse() { + return $this->_last_http_client + ? $this->_last_http_client->getLastResponse() + : null; + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/InspectorGadget.php b/library/ZendAfi/Controller/Plugin/InspectorGadget.php index ad00e0cdb78318e5bcb19ab8aa7caa0fd40a14a3..687b03cf6243ebcab7835e9de67a13a12e2cb846 100644 --- a/library/ZendAfi/Controller/Plugin/InspectorGadget.php +++ b/library/ZendAfi/Controller/Plugin/InspectorGadget.php @@ -142,7 +142,7 @@ onclick="$(\'[data-type=' . self::PARAM_NAME . '-' . $content . ']\').dialog({ti public function log() { - $httpClient = Class_HttpClientFactory::getInstance()->newHttpClient(); + $httpClient = Class_HttpClientFactory::getInstance()->getLastHttpClient(); $response_code = $response_body = null; if ($response = $httpClient->getLastResponse()) { $response_code = $response->getStatus();