4
4
5
5
namespace Http \Client \Common ;
6
6
7
- use Http \Client \Exception as HttplugException ;
8
7
use Http \Client \HttpAsyncClient ;
9
8
use Http \Client \HttpClient ;
10
- use Http \Client \Promise \HttpFulfilledPromise ;
11
- use Http \Client \Promise \HttpRejectedPromise ;
12
9
use Psr \Http \Client \ClientInterface ;
13
10
use Psr \Http \Message \RequestInterface ;
14
11
use Psr \Http \Message \ResponseInterface ;
@@ -24,7 +21,7 @@ final class PluginClient implements HttpClient, HttpAsyncClient
24
21
/**
25
22
* An HTTP async client.
26
23
*
27
- * @var HttpAsyncClient|HttpClient
24
+ * @var HttpAsyncClient
28
25
*/
29
26
private $ client ;
30
27
@@ -71,22 +68,7 @@ public function __construct($client, array $plugins = [], array $options = [])
71
68
*/
72
69
public function sendRequest (RequestInterface $ request ): ResponseInterface
73
70
{
74
- // If we don't have an http client, use the async call
75
- if (!($ this ->client instanceof ClientInterface)) {
76
- return $ this ->sendAsyncRequest ($ request )->wait ();
77
- }
78
-
79
- // Else we want to use the synchronous call of the underlying client, and not the async one in the case
80
- // we have both an async and sync call
81
- $ pluginChain = $ this ->createPluginChain ($ this ->plugins , function (RequestInterface $ request ) {
82
- try {
83
- return new HttpFulfilledPromise ($ this ->client ->sendRequest ($ request ));
84
- } catch (HttplugException $ exception ) {
85
- return new HttpRejectedPromise ($ exception );
86
- }
87
- });
88
-
89
- return $ pluginChain ($ request )->wait ();
71
+ return $ this ->sendAsyncRequest ($ request )->wait ();
90
72
}
91
73
92
74
/**
0 commit comments