You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR was squashed before being merged into the 4.4 branch (closessymfony#33743).
Discussion
----------
[HttpClient] Async HTTPlug client
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | Fixsymfony#33710, Fixsymfony#32142
| License | MIT
| Doc PR | symfony/symfony-docs#12389
This PR removes `HttplugClient`'s dependency on `Psr18Client`. It will also add an `HttplugPromise` to make sure we sure we respect the Httplug's `HttpAsyncClient` interface.
It implements `HttpAsyncClient::sendAsyncRequest()` and provides two extensions:
- `HttplugPromise::cancel()` allows cancelling a promise (and the underlying response)
- `HttplugClient::wait()` allows to tick the promise pool, with configurable timeouts.
Commits
-------
4fd593f [HttpClient] Async HTTPlug client
thrownew \LogicException('You cannot use "Symfony\Component\HttpClient\HttplugClient" as the "php-http/httplug" package is not installed. Try running "composer require php-http/httplug".');
33
44
}
34
45
35
-
if (!interface_exists(ClientInterface::class)) {
36
-
thrownew \LogicException('You cannot use "Symfony\Component\HttpClient\HttplugClient" as the "psr/http-client" package is not installed. Try running "composer require psr/http-client".');
37
-
}
38
-
39
46
if (!interface_exists(RequestFactory::class)) {
40
47
thrownew \LogicException('You cannot use "Symfony\Component\HttpClient\HttplugClient" as the "php-http/message-factory" package is not installed. Try running "composer require nyholm/psr7".');
41
48
}
42
49
43
50
/**
44
51
* An adapter to turn a Symfony HttpClientInterface into an Httplug client.
45
52
*
46
-
* Run "composer require psr/http-client" to install the base ClientInterface. Run
47
-
* "composer require nyholm/psr7" to install an efficient implementation of response
53
+
* Run "composer require nyholm/psr7" to install an efficient implementation of response
48
54
* and stream factories with flex-provided autowiring aliases.
if (null !== $this->responseFactory && null !== $this->streamFactory) {
74
+
return;
75
+
}
76
+
77
+
if (!class_exists(Psr17Factory::class)) {
78
+
thrownew \LogicException('You cannot use the "Symfony\Component\HttpClient\HttplugClient" as no PSR-17 factories have been provided. Try running "composer require nyholm/psr7".');
thrownew \LogicException(sprintf('You cannot use "%s()" as the "guzzlehttp/promises" package is not installed. Try running "composer require guzzlehttp/promises".', __METHOD__));
thrownew \LogicException(sprintf('You cannot use "%s()" as the "nyholm/psr7" package is not installed. Try running "composer require nyholm/psr7".', __METHOD__));
208
+
} else {
209
+
$request = newRequest($method, $uri);
210
+
}
211
+
212
+
$request = $request
82
213
->withProtocolVersion($protocolVersion)
83
214
->withBody($this->createStream($body))
84
215
;
@@ -100,27 +231,84 @@ public function createStream($body = null): StreamInterface
if ($this->responseFactoryinstanceof UriFactoryInterface) {
258
+
return$this->responseFactory->createUri($uri);
259
+
}
260
+
261
+
if (!class_exists(Uri::class)) {
262
+
thrownew \LogicException(sprintf('You cannot use "%s()" as the "nyholm/psr7" package is not installed. Try running "composer require nyholm/psr7".', __METHOD__));
0 commit comments