Goutte\Client::createResponse PHP Method

createResponse() protected method

protected createResponse ( Psr\Http\Message\ResponseInterface $response )
$response Psr\Http\Message\ResponseInterface
    protected function createResponse(ResponseInterface $response)
    {
        return new Response((string) $response->getBody(), $response->getStatusCode(), $response->getHeaders());
    }

Usage Example

Example #1
0
 /**
  * Reads response meta tags to guess content-type charset.
  */
 protected function createResponse(GuzzleResponse $response)
 {
     $body = $response->getBody(true);
     $contentType = $response->getContentType();
     if (!$contentType || false === strpos($contentType, 'charset=')) {
         if (preg_match('/\\<meta[^\\>]+charset *= *["\']?([a-zA-Z\\-0-9]+)/i', $body, $matches)) {
             $contentType .= ';charset=' . $matches[1];
         }
     }
     $response->setHeader('Content-Type', $contentType);
     return parent::createResponse($response);
 }