TraceableHttpClient
in package
implements
HttpClientInterface, ResetInterface, LoggerAwareInterface
FinalYes
Tags
Table of Contents
Interfaces
- HttpClientInterface
- Provides flexible methods for requesting HTTP resources synchronously or asynchronously.
- ResetInterface
- Provides a way to reset an object to its initial state.
- LoggerAwareInterface
- Describes a logger-aware instance.
Properties
- $client : HttpClientInterface
- $disabled : Closure|null
- $stopwatch : Stopwatch|null
- $tracedRequests : ArrayObject
Methods
- __construct() : mixed
- getTracedRequests() : array<string|int, mixed>
- request() : ResponseInterface
- Requests an HTTP resource.
- reset() : void
- setLogger() : void
- Sets a logger instance on the object.
- stream() : ResponseStreamInterface
- Yields responses chunk by chunk as they complete.
- withOptions() : static
- Returns a new instance of the client with new default options.
Properties
$client
private
HttpClientInterface
$client
$disabled
private
Closure|null
$disabled
= null
$stopwatch
private
Stopwatch|null
$stopwatch
= null
$tracedRequests
private
ArrayObject
$tracedRequests
Methods
__construct()
public
__construct(HttpClientInterface $client[, Stopwatch|null $stopwatch = null ][, Closure|null $disabled = null ]) : mixed
Parameters
- $client : HttpClientInterface
- $stopwatch : Stopwatch|null = null
- $disabled : Closure|null = null
getTracedRequests()
public
getTracedRequests() : array<string|int, mixed>
Return values
array<string|int, mixed>request()
Requests an HTTP resource.
public
request(string $method, string $url[, array<string|int, mixed> $options = [] ]) : ResponseInterface
Responses MUST be lazy, but their status code MUST be checked even if none of their public methods are called.
Implementations are not required to support all options described above; they can also support more custom options; but in any case, they MUST throw a TransportExceptionInterface when an unsupported option is passed.
Parameters
- $method : string
- $url : string
- $options : array<string|int, mixed> = []
Return values
ResponseInterfacereset()
public
reset() : void
setLogger()
Sets a logger instance on the object.
public
setLogger(LoggerInterface $logger) : void
since Symfony 7.1, configure the logger on the wrapped HTTP client directly instead
Parameters
- $logger : LoggerInterface
stream()
Yields responses chunk by chunk as they complete.
public
stream(ResponseInterface|iterable<string|int, mixed> $responses[, float|null $timeout = null ]) : ResponseStreamInterface
Parameters
- $responses : ResponseInterface|iterable<string|int, mixed>
-
One or more responses created by the current HTTP client
- $timeout : float|null = null
-
The idle timeout before yielding timeout chunks
Return values
ResponseStreamInterfacewithOptions()
Returns a new instance of the client with new default options.
public
withOptions(array<string|int, mixed> $options) : static
Parameters
- $options : array<string|int, mixed>