-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Socket to support HTTP over Unix domain sockets (UDS)
- Loading branch information
Showing
3 changed files
with
67 additions
and
1 deletion.
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,39 @@ | ||
<?php | ||
|
||
use React\HttpClient\Client; | ||
use React\HttpClient\Response; | ||
use React\Socket\FixedUriConnector; | ||
use React\Socket\UnixConnector; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$loop = React\EventLoop\Factory::create(); | ||
|
||
$connector = new FixedUriConnector( | ||
'unix:///var/run/docker.sock', | ||
new UnixConnector($loop) | ||
); | ||
|
||
$client = new Client($loop, $connector); | ||
|
||
$request = $client->request('GET', 'http://localhost/info'); | ||
|
||
$request->on('response', function (Response $response) { | ||
var_dump($response->getHeaders()); | ||
|
||
$response->on('data', function ($chunk) { | ||
echo $chunk; | ||
}); | ||
|
||
$response->on('end', function () { | ||
echo 'DONE' . PHP_EOL; | ||
}); | ||
}); | ||
|
||
$request->on('error', function (\Exception $e) { | ||
echo $e; | ||
}); | ||
|
||
$request->end(); | ||
|
||
$loop->run(); |