You are here

protected function Client::filterResponse in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-kernel/Client.php \Symfony\Component\HttpKernel\Client::filterResponse()
  2. 8 vendor/symfony/browser-kit/Client.php \Symfony\Component\BrowserKit\Client::filterResponse()
  3. 8 vendor/behat/mink-goutte-driver/src/Goutte/Client.php \Behat\Mink\Driver\Goutte\Client::filterResponse()
Same name and namespace in other branches
  1. 8.0 vendor/behat/mink-goutte-driver/src/Goutte/Client.php \Behat\Mink\Driver\Goutte\Client::filterResponse()

Reads response meta tags to guess content-type charset.

Parameters

Response $response:

Return value

Response

Overrides Client::filterResponse

File

vendor/behat/mink-goutte-driver/src/Goutte/Client.php, line 28

Class

Client
Client overrides to support Mink functionality.

Namespace

Behat\Mink\Driver\Goutte

Code

protected function filterResponse($response) {
  $contentType = $response
    ->getHeader('Content-Type');
  if (!$contentType || false === strpos($contentType, 'charset=')) {
    if (preg_match('/\\<meta[^\\>]+charset *= *["\']?([a-zA-Z\\-0-9]+)/i', $response
      ->getContent(), $matches)) {
      $headers = $response
        ->getHeaders();
      $headers['Content-Type'] = $contentType . ';charset=' . $matches[1];
      $response = new Response($response
        ->getContent(), $response
        ->getStatus(), $headers);
    }
  }
  return parent::filterResponse($response);
}