You are here

private function RedirectMiddleware::redirectUri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php \GuzzleHttp\RedirectMiddleware::redirectUri()

Set the appropriate URL on the request based on the location header

Parameters

RequestInterface $request:

ResponseInterface $response:

array $protocols:

Return value

UriInterface

1 call to RedirectMiddleware::redirectUri()
RedirectMiddleware::modifyRequest in vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php

File

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

Class

RedirectMiddleware
Request redirect middleware.

Namespace

GuzzleHttp

Code

private function redirectUri(RequestInterface $request, ResponseInterface $response, array $protocols) {
  $location = Psr7\Uri::resolve($request
    ->getUri(), $response
    ->getHeaderLine('Location'));

  // Ensure that the redirect URI is allowed based on the protocols.
  if (!in_array($location
    ->getScheme(), $protocols)) {
    throw new BadResponseException(sprintf('Redirect URI, %s, does not use one of the allowed redirect protocols: %s', $location, implode(', ', $protocols)), $request, $response);
  }
  return $location;
}