|
static | cookies () |
| Middleware that adds cookies to requests.
|
|
static | history (&$container) |
| Middleware that pushes history data to an ArrayAccess container.
|
|
static | httpErrors (BodySummarizerInterface $bodySummarizer=null) |
| Middleware that throws exceptions for 4xx or 5xx responses when the "http_errors" request option is set to true.
|
|
static | log (LoggerInterface $logger, $formatter, string $logLevel='info') |
| Middleware that logs requests, responses, and errors using a message formatter.
|
|
static | mapRequest (callable $fn) |
| Middleware that applies a map function to the request before passing to the next handler.
|
|
static | mapResponse (callable $fn) |
| Middleware that applies a map function to the resolved promise's response.
|
|
static | prepareBody () |
| This middleware adds a default content-type if possible, a default content-length or transfer-encoding header, and the expect header.
|
|
static | redirect () |
| Middleware that handles request redirects.
|
|
static | retry (callable $decider, callable $delay=null) |
| Middleware that retries requests based on the boolean result of invoking the provided "decider" function.
|
|
static | tap (callable $before=null, callable $after=null) |
| Middleware that invokes a callback before and after sending a request.
|
|
◆ cookies()
static GuzzleHttp\Middleware::cookies |
( |
| ) |
|
|
static |
Middleware that adds cookies to requests.
The options array must be set to a CookieJarInterface in order to use cookies. This is typically handled for you by a client.
- Return values
-
callable | Returns a function that accepts the next handler. |
◆ history()
static GuzzleHttp\Middleware::history |
( |
& | $container | ) |
|
|
static |
Middleware that pushes history data to an ArrayAccess container.
- Parameters
-
array|ArrayAccess<int,array> | $container Container to hold the history (by reference). |
- Return values
-
callable(callable) | callable Returns a function that accepts the next handler. |
- Exceptions
-
InvalidArgumentException | if container is not an array or ArrayAccess. |
◆ httpErrors()
Middleware that throws exceptions for 4xx or 5xx responses when the "http_errors" request option is set to true.
- Parameters
-
BodySummarizerInterface | null | $bodySummarizer | The body summarizer to use in exception messages. |
- Return values
-
callable(callable) | callable Returns a function that accepts the next handler. |
◆ log()
static GuzzleHttp\Middleware::log |
( |
LoggerInterface | $logger, |
|
|
| $formatter, |
|
|
string | $logLevel = 'info' ) |
|
static |
Middleware that logs requests, responses, and errors using a message formatter.
@phpstan-param Psr\Log\LogLevel::* $logLevel Level at which to log requests.
- Parameters
-
LoggerInterface | $logger | Logs messages. |
MessageFormatterInterface | MessageFormatter | $formatter | Formatter used to create message strings. |
string | $logLevel | Level at which to log requests. |
- Return values
-
callable | Returns a function that accepts the next handler. |
◆ mapRequest()
static GuzzleHttp\Middleware::mapRequest |
( |
callable | $fn | ) |
|
|
static |
Middleware that applies a map function to the request before passing to the next handler.
- Parameters
-
callable | $fn | Function that accepts a RequestInterface and returns a RequestInterface. |
◆ mapResponse()
static GuzzleHttp\Middleware::mapResponse |
( |
callable | $fn | ) |
|
|
static |
Middleware that applies a map function to the resolved promise's response.
- Parameters
-
callable | $fn | Function that accepts a ResponseInterface and returns a ResponseInterface. |
◆ redirect()
static GuzzleHttp\Middleware::redirect |
( |
| ) |
|
|
static |
Middleware that handles request redirects.
- Return values
-
callable | Returns a function that accepts the next handler. |
◆ retry()
static GuzzleHttp\Middleware::retry |
( |
callable | $decider, |
|
|
callable | $delay = null ) |
|
static |
Middleware that retries requests based on the boolean result of invoking the provided "decider" function.
If no delay function is provided, a simple implementation of exponential backoff will be utilized.
- Parameters
-
callable | $decider | Function that accepts the number of retries, a request, [response], and [exception] and returns true if the request is to be retried. |
callable | $delay | Function that accepts the number of retries and returns the number of milliseconds to delay. |
- Return values
-
callable | Returns a function that accepts the next handler. |
◆ tap()
static GuzzleHttp\Middleware::tap |
( |
callable | $before = null, |
|
|
callable | $after = null ) |
|
static |
Middleware that invokes a callback before and after sending a request.
The provided listener cannot modify or alter the response. It simply "taps" into the chain to be notified before returning the promise. The before listener accepts a request and options array, and the after listener accepts a request, options array, and response promise.
- Parameters
-
callable | $before | Function to invoke before forwarding the request. |
callable | $after | Function invoked after forwarding. |
- Return values
-
callable | Returns a function that accepts the next handler. |
The documentation for this class was generated from the following file:
- lib/guzzlehttp/guzzle/src/Middleware.php