-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5a84ba
commit abc6631
Showing
7 changed files
with
76 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
// A simple example which uses an HTTP client to request https://example.com/ through an HTTP CONNECT proxy. | ||
// You can use any kind of proxy, for example https://github.com/leproxy/leproxy and excecute it like this: | ||
// | ||
// $ php leproxy-latest.php | ||
// | ||
// To run the example, go to the project root and run: | ||
// | ||
// $ php examples/01-http-requests.php | ||
// | ||
// Make sure you're referencing the right proxy adress inside the ProxyConnector | ||
|
||
use React\HTTP\Browser; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$loop = React\EventLoop\Factory::create(); | ||
$proxy = new Clue\React\HttpProxy\ProxyConnector('127.0.0.1:8080', new React\Socket\Connector($loop)); | ||
|
||
$connector = new React\Socket\Connector($loop, array( | ||
'tcp' => $proxy, | ||
'dns' => false | ||
)); | ||
|
||
$browser = new React\Http\Browser($loop, $connector); | ||
|
||
$browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) { | ||
var_dump($response->getHeaders(), (string) $response->getBody()); | ||
}, 'printf'); | ||
|
||
$loop->run(); |
10 changes: 9 additions & 1 deletion
10
examples/01-proxy-https.php → examples/11-proxy-raw-https-protocol.php
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
10 changes: 9 additions & 1 deletion
10
examples/03-custom-proxy-headers.php → examples/13-custom-proxy-headers.php
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
12 changes: 10 additions & 2 deletions
12
examples/11-proxy-smtp.php → examples/21-proxy-raw-smtp-protocol.php
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
12 changes: 10 additions & 2 deletions
12
examples/12-proxy-smtps.php → examples/22-proxy-raw-smtps-protocol.php
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