/** * Returns an HTML-formatted string representation of the exception. * * @return string * @internal */ public function __toString() { $msg = $this->getMessage(); if (is_object($this->requestObj) && $this->requestObj instanceof \Guzzle\Http\Message\Request) { $request = array('url' => $this->requestObj->getUrl(), 'host' => $this->requestObj->getHost(), 'headers' => $this->requestObj->getRawHeaders(), 'query' => (string) $this->requestObj->getQuery()); if ($this->requestObj instanceof \Guzzle\Http\Message\EntityEnclosingRequestInterface) { $request_body = $this->requestObj->getBody(); $request['content-type'] = $request_body->getContentType(); $request['content-length'] = $request_body->getContentLength(); $request['body'] = $request_body->__toString(); } $msg .= "\n\nRequest: <pre>" . htmlspecialchars(print_r($request, true)) . '</pre>'; } if (is_object($this->responseObj) && $this->responseObj instanceof \Guzzle\Http\Message\Response) { $response = array('status' => $this->responseObj->getStatusCode(), 'headers' => $this->responseObj->getRawHeaders(), 'body' => $this->responseBody); $msg .= "\n\nResponse: <pre>" . htmlspecialchars(print_r($response, true)) . '</pre>'; } return $msg; }
/** * @covers Guzzle\Http\Message\Response::getRawHeaders */ public function testGetRawHeaders() { $response = new Response(200, new Collection(array('Keep-Alive' => 155, 'User-Agent' => 'Guzzle', 'Content-Length' => 4)), 'body'); $this->assertEquals("HTTP/1.1 200 OK\r\nKeep-Alive: 155\r\nUser-Agent: Guzzle\r\nContent-Length: 4\r\n\r\n", $response->getRawHeaders()); }
protected function processGuzzleResponse(Response $response) { $this->processResponseHeaders($response->getRawHeaders()); $this->processResponseBody($response->getBody(true)); }
/** * {@inheritdoc} */ public function getRawHeaders() { return $this->response->getRawHeaders(); }