-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from clue-labs/unix
Update Socket dependency and support Unix Domain Sockets (UDS) again
- Loading branch information
Showing
3 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Clue\React\Buzz\Browser; | ||
use Psr\Http\Message\ResponseInterface; | ||
use React\EventLoop\Factory as LoopFactory; | ||
use React\Socket\FixedUriConnector; | ||
use React\Socket\UnixConnector; | ||
use RingCentral\Psr7; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$loop = LoopFactory::create(); | ||
|
||
// create a Browser object that uses the a Unix Domain Sockets (UDS) path for all requests | ||
$connector = new FixedUriConnector( | ||
'unix:///var/run/docker.sock', | ||
new UnixConnector($loop) | ||
); | ||
|
||
$browser = new Browser($loop, $connector); | ||
|
||
// demo fetching HTTP headers (or bail out otherwise) | ||
$browser->get('http://localhost/info')->then(function (ResponseInterface $response) { | ||
echo Psr7\str($response); | ||
}, 'printf'); | ||
|
||
$loop->run(); |