Guzzle 7.4.2

RedirectMiddleware
in package

Request redirect middleware.

Apply this middleware like other middleware using Middleware::redirect().

Tags
final

Table of Contents

HISTORY_HEADER  = 'X-Guzzle-Redirect-History'
STATUS_HISTORY_HEADER  = 'X-Guzzle-Redirect-Status-History'
$defaultSettings  : array<string|int, mixed>
$nextHandler  : mixed
__construct()  : mixed
__invoke()  : PromiseInterface
checkRedirect()  : ResponseInterface|PromiseInterface
modifyRequest()  : RequestInterface
guardMax()  : void
Check for too many redirects
redirectUri()  : UriInterface
Set the appropriate URL on the request based on the location header
withTracking()  : PromiseInterface
Enable tracking on promise.

Constants

STATUS_HISTORY_HEADER

public mixed STATUS_HISTORY_HEADER = 'X-Guzzle-Redirect-Status-History'

Properties

$defaultSettings

public static array<string|int, mixed> $defaultSettings = ['max' => 5, 'protocols' => ['http', 'https'], 'strict' => false, 'referer' => false, 'track_redirects' => false]

$nextHandler

private mixed $nextHandler

callable(RequestInterface, array): PromiseInterface

Methods

__construct()

public __construct(callable $nextHandler) : mixed
Parameters
$nextHandler : callable
Return values
mixed

__invoke()

public __invoke(RequestInterface $request, array<string|int, mixed> $options) : PromiseInterface
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
Return values
PromiseInterface

checkRedirect()

public checkRedirect(RequestInterface $request, array<string|int, mixed> $options, ResponseInterface $response) : ResponseInterface|PromiseInterface
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$response : ResponseInterface
Return values
ResponseInterface|PromiseInterface

modifyRequest()

public modifyRequest(RequestInterface $request, array<string|int, mixed> $options, ResponseInterface $response) : RequestInterface
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$response : ResponseInterface
Return values
RequestInterface

guardMax()

Check for too many redirects

private guardMax(RequestInterface $request, ResponseInterface $response, array<string|int, mixed> &$options) : void
Parameters
$request : RequestInterface
$response : ResponseInterface
$options : array<string|int, mixed>
Tags
throws
TooManyRedirectsException

Too many redirects.

Return values
void

redirectUri()

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

private redirectUri(RequestInterface $request, ResponseInterface $response, array<string|int, mixed> $protocols) : UriInterface
Parameters
$request : RequestInterface
$response : ResponseInterface
$protocols : array<string|int, mixed>
Return values
UriInterface

withTracking()

Enable tracking on promise.

private withTracking(PromiseInterface $promise, string $uri, int $statusCode) : PromiseInterface
Parameters
$promise : PromiseInterface
$uri : string
$statusCode : int
Return values
PromiseInterface

Search results