RedirectMiddleware
in package
Request redirect middleware.
Apply this middleware like other middleware using Middleware::redirect().
Table of Contents
- HISTORY_HEADER = 'X-Guzzle-Redirect-History'
- STATUS_HISTORY_HEADER = 'X-Guzzle-Redirect-Status-History'
- $defaultSettings : mixed
- $nextHandler : callable
- __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
HISTORY_HEADER
public
mixed
HISTORY_HEADER
= 'X-Guzzle-Redirect-History'
STATUS_HISTORY_HEADER
public
mixed
STATUS_HISTORY_HEADER
= 'X-Guzzle-Redirect-Status-History'
Properties
$defaultSettings
public
static mixed
$defaultSettings
= ['max' => 5, 'protocols' => ['http', 'https'], 'strict' => false, 'referer' => false, 'track_redirects' => false]
$nextHandler
private
callable
$nextHandler
Methods
__construct()
public
__construct(callable $nextHandler) : mixed
Parameters
- $nextHandler : callable
-
Next handler to invoke.
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, array<string|int, mixed> &$options) : void
Parameters
- $request : RequestInterface
- $options : array<string|int, mixed>
Tags
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, mixed $uri, mixed $statusCode) : PromiseInterface
Parameters
- $promise : PromiseInterface
- $uri : mixed
- $statusCode : mixed