コード例 #1
0
ファイル: CakeHttpAdapter.php プロジェクト: lamenath/fbp
 /**
  * {@inheritdoc}
  */
 protected function doSendInternalRequest(InternalRequestInterface $internalRequest)
 {
     $this->httpSocket->config['timeout'] = $this->getConfiguration()->getTimeout();
     $request = array('version' => $this->getConfiguration()->getProtocolVersion(), 'redirect' => false, 'uri' => $url = (string) $internalRequest->getUrl(), 'method' => $internalRequest->getMethod(), 'header' => $this->prepareHeaders($internalRequest), 'body' => $this->prepareBody($internalRequest));
     try {
         $response = $this->httpSocket->request($request);
     } catch (\Exception $e) {
         throw HttpAdapterException::cannotFetchUrl($url, $this->getName(), $e->getMessage());
     }
     if (($error = $this->httpSocket->lastError()) !== null) {
         throw HttpAdapterException::cannotFetchUrl($url, $this->getName(), $error);
     }
     return $this->getConfiguration()->getMessageFactory()->createResponse((int) $response->code, $response->reasonPhrase, ProtocolVersionExtractor::extract($response->httpVersion), $response->headers, BodyNormalizer::normalize($response->body, $internalRequest->getMethod()));
 }