Example #1
0
 /**
  * Send a request and return the response.
  *
  * @param \Zend\Http\Client $client Prepare HTTP client
  *
  * @return string Response body
  *
  * @throws \VuFindSearch\Backend\Exception\RemoteErrorException  Server
  * signaled a server error (HTTP 5xx)
  * @throws \VuFindSearch\Backend\Exception\RequestErrorException Server
  * signaled a client error (HTTP 4xx)
  */
 protected function send(\Zend\Http\Client $client)
 {
     $this->debug(sprintf('=> %s %s', $client->getMethod(), $client->getUri()));
     $time = microtime(true);
     $response = $client->send();
     $time = microtime(true) - $time;
     $this->debug(sprintf('<= %s %s', $response->getStatusCode(), $response->getReasonPhrase()), ['time' => $time]);
     if (!$response->isSuccess()) {
         throw HttpErrorException::createFromResponse($response);
     }
     return $response->getBody();
 }