You are here

protected function Client::filterResponse in Zircon Profile 8.0

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

Converts the HttpKernel response to a BrowserKit response.

Parameters

Response $response A Response instance:

Return value

DomResponse A DomResponse instance

Overrides Client::filterResponse

File

vendor/symfony/http-kernel/Client.php, line 208

Class

Client
Client simulates a browser and makes requests to a Kernel object.

Namespace

Symfony\Component\HttpKernel

Code

protected function filterResponse($response) {
  $headers = $response->headers
    ->all();
  if ($response->headers
    ->getCookies()) {
    $cookies = array();
    foreach ($response->headers
      ->getCookies() as $cookie) {
      $cookies[] = new DomCookie($cookie
        ->getName(), $cookie
        ->getValue(), $cookie
        ->getExpiresTime(), $cookie
        ->getPath(), $cookie
        ->getDomain(), $cookie
        ->isSecure(), $cookie
        ->isHttpOnly());
    }
    $headers['Set-Cookie'] = $cookies;
  }

  // this is needed to support StreamedResponse
  ob_start();
  $response
    ->sendContent();
  $content = ob_get_clean();
  return new DomResponse($content, $response
    ->getStatusCode(), $headers);
}