You are here

public function Client::followRedirect in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/browser-kit/Client.php \Symfony\Component\BrowserKit\Client::followRedirect()

Follow redirects?

Return value

Crawler

Throws

\LogicException If request was not a redirect

1 call to Client::followRedirect()
Client::request in vendor/symfony/browser-kit/Client.php
Calls a URI.

File

vendor/symfony/browser-kit/Client.php, line 445

Class

Client
Client simulates a browser.

Namespace

Symfony\Component\BrowserKit

Code

public function followRedirect() {
  if (empty($this->redirect)) {
    throw new \LogicException('The request was not redirected.');
  }
  if (-1 !== $this->maxRedirects) {
    if ($this->redirectCount > $this->maxRedirects) {
      throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects));
    }
  }
  $request = $this->internalRequest;
  if (in_array($this->internalResponse
    ->getStatus(), array(
    302,
    303,
  ))) {
    $method = 'get';
    $files = array();
    $content = null;
  }
  else {
    $method = $request
      ->getMethod();
    $files = $request
      ->getFiles();
    $content = $request
      ->getContent();
  }
  if ('get' === strtolower($method)) {

    // Don't forward parameters for GET request as it should reach the redirection URI
    $parameters = array();
  }
  else {
    $parameters = $request
      ->getParameters();
  }
  $server = $request
    ->getServer();
  $server = $this
    ->updateServerFromUri($server, $this->redirect);
  $this->isMainRequest = false;
  $response = $this
    ->request($method, $this->redirect, $parameters, $files, $server, $content);
  $this->isMainRequest = true;
  return $response;
}