You are here

public function RedirectMiddleware::checkRedirect in Auth0 Single Sign On 8.2

Parameters

RequestInterface $request:

array $options:

ResponseInterface $response:

Return value

ResponseInterface|PromiseInterface

1 call to RedirectMiddleware::checkRedirect()
RedirectMiddleware::__invoke in vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php

File

vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php, line 83

Class

RedirectMiddleware
Request redirect middleware.

Namespace

GuzzleHttp

Code

public function checkRedirect(RequestInterface $request, array $options, ResponseInterface $response) {
  if (substr($response
    ->getStatusCode(), 0, 1) != '3' || !$response
    ->hasHeader('Location')) {
    return $response;
  }
  $this
    ->guardMax($request, $options);
  $nextRequest = $this
    ->modifyRequest($request, $options, $response);
  if (isset($options['allow_redirects']['on_redirect'])) {
    call_user_func($options['allow_redirects']['on_redirect'], $request, $response, $nextRequest
      ->getUri());
  }

  /** @var PromiseInterface|ResponseInterface $promise */
  $promise = $this($nextRequest, $options);

  // Add headers to be able to track history of redirects.
  if (!empty($options['allow_redirects']['track_redirects'])) {
    return $this
      ->withTracking($promise, (string) $nextRequest
      ->getUri(), $response
      ->getStatusCode());
  }
  return $promise;
}