Skip to content

Discovery support #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
"php-http/httplug": "^1.0",
"react/http-client": "^0.4.8",
"react/dns": "^0.4.1",
"react/stream": "^0.4.3"
"react/stream": "^0.4.3",
"php-http/discovery": "^0.8"
},
"require-dev": {
"guzzlehttp/psr7": "^1.0",
"php-http/adapter-integration-tests": "^0.3.1",
"puli/composer-plugin": "1.0.0-beta9"
"php-http/adapter-integration-tests": "^0.4"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 7 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Http\Adapter\React;

use Http\Discovery\MessageFactoryDiscovery;
use Psr\Http\Message\ResponseInterface;
use React\EventLoop\LoopInterface;
use React\Promise\Deferred;
Expand Down Expand Up @@ -38,7 +39,7 @@ class Client implements HttpClient, HttpAsyncClient
private $loop;

/**
* HttpPlug message factory.
* HTTPlug message factory.
*
* @var MessageFactory
*/
Expand All @@ -47,12 +48,12 @@ class Client implements HttpClient, HttpAsyncClient
/**
* Initialize the React client.
*
* @param MessageFactory $messageFactory
* @param LoopInterface|null $loop React Event loop
* @param ReactClient $client React client to use
* @param MessageFactory|null $messageFactory
* @param LoopInterface|null $loop React Event loop
* @param ReactClient|null $client React client to use
*/
public function __construct(
MessageFactory $messageFactory,
MessageFactory $messageFactory = null,
LoopInterface $loop = null,
ReactClient $client = null
) {
Expand All @@ -64,7 +65,7 @@ public function __construct(
$this->loop = (null !== $loop) ?: ReactFactory::buildEventLoop();
$this->client = (null !== $client) ?: ReactFactory::buildHttpClient($this->loop);

$this->messageFactory = $messageFactory;
$this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find();
}

/**
Expand Down
5 changes: 2 additions & 3 deletions tests/AsyncClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Http\Adapter\React\Tests;

use Http\Client\HttpClient;
use Http\Discovery\MessageFactoryDiscovery;
use Http\Client\Tests\HttpAsyncClientTest;
use Http\Adapter\React\Client;
use Http\Message\MessageFactory\GuzzleMessageFactory;

/**
* @author Stéphane Hulard <stephane@hlrd.me>
Expand All @@ -17,7 +17,6 @@ class AsyncClientTest extends HttpAsyncClientTest
*/
protected function createHttpAsyncClient()
{
$messageFactory = MessageFactoryDiscovery::find();
return new Client($messageFactory);
return new Client(new GuzzleMessageFactory());
}
}
5 changes: 2 additions & 3 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Http\Client\HttpClient;
use Http\Client\Tests\HttpClientTest;
use Http\Adapter\React\Client;
use Http\Discovery\MessageFactoryDiscovery;
use Http\Message\MessageFactory\GuzzleMessageFactory;

/**
* @author Stéphane Hulard <stephane@hlrd.me>
Expand All @@ -17,7 +17,6 @@ class ClientTest extends HttpClientTest
*/
protected function createHttpAdapter()
{
$messageFactory = MessageFactoryDiscovery::find();
return new Client($messageFactory);
return new Client(new GuzzleMessageFactory());
}
}