-
-
Notifications
You must be signed in to change notification settings - Fork 145
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 #410 from clue-labs/default-loop
Simplify usage by supporting new default loop
- Loading branch information
Showing
38 changed files
with
240 additions
and
329 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
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
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 |
---|---|---|
@@ -1,29 +1,25 @@ | ||
<?php | ||
|
||
use React\Http\Browser; | ||
use Clue\React\SshProxy\SshSocksConnector; | ||
use Psr\Http\Message\ResponseInterface; | ||
use React\EventLoop\Factory as LoopFactory; | ||
use React\EventLoop\Loop; | ||
use React\Http\Browser; | ||
use React\Socket\Connector; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$loop = LoopFactory::create(); | ||
|
||
// create a new SSH proxy client which connects to a SSH server listening on localhost:22 | ||
// You can pass any SSH server address as first argument, e.g. user@example.com | ||
$proxy = new SshSocksConnector(isset($argv[1]) ? $argv[1] : 'localhost:22', $loop); | ||
$proxy = new SshSocksConnector(isset($argv[1]) ? $argv[1] : 'localhost:22', Loop::get()); | ||
|
||
// create a Browser object that uses the SSH proxy client for connections | ||
$connector = new Connector($loop, array( | ||
$connector = new Connector(null, array( | ||
'tcp' => $proxy, | ||
'dns' => false | ||
)); | ||
$browser = new Browser($loop, $connector); | ||
$browser = new Browser(null, $connector); | ||
|
||
// demo fetching HTTP headers (or bail out otherwise) | ||
$browser->get('https://www.google.com/')->then(function (ResponseInterface $response) { | ||
echo RingCentral\Psr7\str($response); | ||
}, 'printf'); | ||
|
||
$loop->run(); |
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 |
---|---|---|
@@ -1,27 +1,22 @@ | ||
<?php | ||
|
||
use React\Http\Browser; | ||
use Psr\Http\Message\ResponseInterface; | ||
use React\EventLoop\Factory as LoopFactory; | ||
use React\Http\Browser; | ||
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) | ||
new UnixConnector() | ||
); | ||
|
||
$browser = new Browser($loop, $connector); | ||
$browser = new Browser(null, $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(); |
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
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
Oops, something went wrong.