4 * This file is part of the Behat\Mink.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Mink\Driver\Goutte;
13 use Goutte\Client as BaseClient;
14 use Symfony\Component\BrowserKit\Response;
17 * Client overrides to support Mink functionality.
19 class Client extends BaseClient
22 * Reads response meta tags to guess content-type charset.
24 * @param Response $response
28 protected function filterResponse($response)
30 $contentType = $response->getHeader('Content-Type');
32 if (!$contentType || false === strpos($contentType, 'charset=')) {
33 if (preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $response->getContent(), $matches)) {
34 $headers = $response->getHeaders();
35 $headers['Content-Type'] = $contentType.';charset='.$matches[1];
37 $response = new Response($response->getContent(), $response->getStatus(), $headers);
41 return parent::filterResponse($response);