Skip to content

Commit 8646f92

Browse files
committed
Use emulated client from client common
1 parent 2cf3aff commit 8646f92

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"php-http/httplug": "1.0.0-beta",
1616
"php-http/message-factory": "^1.0",
1717
"php-http/promise": "^0.1.1",
18-
"php-http/client-common": "^0.1",
18+
"php-http/client-common": "^0.2@dev",
1919
"symfony/options-resolver": "^2.6|^3.0"
2020
},
2121
"require-dev": {

src/EmulateAsyncClient.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/PluginClient.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Http\Client\Plugin;
44

5+
use Http\Client\Common\EmulatedHttpAsyncClient;
56
use Http\Client\Exception;
67
use Http\Client\HttpAsyncClient;
78
use Http\Client\HttpClient;
@@ -51,7 +52,7 @@ public function __construct($client, array $plugins = [], array $options = [])
5152
if ($client instanceof HttpAsyncClient) {
5253
$this->client = $client;
5354
} elseif ($client instanceof HttpClient) {
54-
$this->client = new EmulateAsyncClient($client);
55+
$this->client = new EmulatedHttpAsyncClient($client);
5556
} else {
5657
throw new \RuntimeException('Client must be an instance of Http\\Client\\HttpClient or Http\\Client\\HttpAsyncClient');
5758
}
@@ -65,10 +66,13 @@ public function __construct($client, array $plugins = [], array $options = [])
6566
*/
6667
public function sendRequest(RequestInterface $request)
6768
{
69+
// If we don't have an http client, use the async call
6870
if (!($this->client instanceof HttpClient)) {
6971
return $this->sendAsyncRequest($request)->wait();
7072
}
7173

74+
// Else we want to use the synchronous call of the underlying client, and not the async one in the case
75+
// we have both an async and sync call
7276
$client = $this->client;
7377
$pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) use ($client) {
7478
try {

0 commit comments

Comments
 (0)