File tree Expand file tree Collapse file tree 6 files changed +45
-16
lines changed
Expand file tree Collapse file tree 6 files changed +45
-16
lines changed Original file line number Diff line number Diff line change 55//
66// $ php leproxy-latest.php
77//
8- // To run the example, go to the project root and run:
8+ // To run the example (The proxy deafults to localhost:8080) , go to the project root and run:
99//
1010// $ php examples/01-http-requests.php
1111//
12- // The proxy can be given as first argument and defaults to localhost:8080 otherwise.
13- use React \HTTP \Browser ;
12+ // If you want to run the same example with any other proxy URL, just use:
13+ //
14+ // $ http_proxy=127.0.0.1.8181 php examples/01-http-requests.php
1415
1516require __DIR__ . '/../vendor/autoload.php ' ;
1617
17- $ url = isset ($ argv [1 ]) ? $ argv [1 ] : '127.0.0.1:8080 ' ;
18+ $ url = getenv ('http_proxy ' );
19+ if ($ url === false ) {
20+ $ url = '127.0.0.1:8080 ' ;
21+ }
1822
1923$ loop = React \EventLoop \Factory::create ();
2024$ proxy = new Clue \React \HttpProxy \ProxyConnector ($ url , new React \Socket \Connector ($ loop ));
Original file line number Diff line number Diff line change 99//
1010// $ php examples/11-proxy-raw-https-protocol.php
1111//
12- // The proxy can be given as first argument and defaults to localhost:8080 otherwise.
12+ // If you want to run the same example with any other proxy URL, just use:
13+ //
14+ // $ http_proxy=127.0.0.1.8181 php examples/11-proxy-raw-https-protocol.php
1315//
1416// For illustration purposes only. If you want to send HTTP requests in a real
1517// world project, take a look at example #01 and https://github.com/reactphp/http#client-usage.
2022
2123require __DIR__ . '/../vendor/autoload.php ' ;
2224
23- $ url = isset ($ argv [1 ]) ? $ argv [1 ] : '127.0.0.1:8080 ' ;
25+ $ url = getenv ('http_proxy ' );
26+ if ($ url === false ) {
27+ $ url = '127.0.0.1:8080 ' ;
28+ }
2429
2530$ loop = React \EventLoop \Factory::create ();
2631
Original file line number Diff line number Diff line change 66//
77// $ php examples/12-optional-proxy-raw-https-protocol.php
88//
9- // The Proxy can be given as first argument or does not use a proxy otherwise.
9+ // To run the same example with your proxy, the proxy URL can be given as an environment variable:
10+ //
11+ // $ http_proxy=127.0.0.1.8181 php examples/12-optional-proxy-raw-https-protocol.php
12+ //
1013// This example highlights how changing from direct connection to using a proxy
1114// actually adds very little complexity and does not mess with your actual
1215// network protocol otherwise.
2427
2528$ connector = new Connector ($ loop );
2629
27- // first argument given? use this as the proxy URL
28- if (isset ( $ argv [ 1 ]) ) {
29- $ proxy = new ProxyConnector ($ argv [ 1 ] , $ connector );
30+ $ url = getenv ( ' http_proxy ' );
31+ if ($ url !== false ) {
32+ $ proxy = new ProxyConnector ($ url , $ connector );
3033 $ connector = new Connector ($ loop , array (
3134 'tcp ' => $ proxy ,
3235 'timeout ' => 3.0 ,
Original file line number Diff line number Diff line change 99//
1010// $ php examples/13-custom-proxy-headers.php
1111//
12- // The proxy can be given as first argument and defaults to localhost:8080 otherwise.
12+ // If you want to run the same example with any other proxy URL, just use:
13+ //
14+ // $ http_proxy=127.0.0.1.8181 php examples/13-custom-proxy-headers.php
1315//
1416// For illustration purposes only. If you want to send HTTP requests in a real
1517// world project, take a look at example #01 and https://github.com/reactphp/http#client-usage.
2022
2123require __DIR__ . '/../vendor/autoload.php ' ;
2224
23- $ url = isset ($ argv [1 ]) ? $ argv [1 ] : '127.0.0.1:8080 ' ;
25+ $ url = getenv ('http_proxy ' );
26+ if ($ url === false ) {
27+ $ url = '127.0.0.1:8080 ' ;
28+ }
2429
2530$ loop = React \EventLoop \Factory::create ();
2631
Original file line number Diff line number Diff line change 99//
1010// $ php examples/21-proxy-raw-smtp-protocol.php
1111//
12- // The proxy can be given as first argument and defaults to localhost:8080 otherwise.
12+ // If you want to run the same example with any other proxy URL, just use:
13+ //
14+ // $ http_proxy=127.0.0.1.8181 php examples/21-proxy-raw-smtp-protocol.php
15+ //
1316// Please note that MANY public proxies do not allow SMTP connections, YMMV.
1417
1518use Clue \React \HttpProxy \ProxyConnector ;
1821
1922require __DIR__ . '/../vendor/autoload.php ' ;
2023
21- $ url = isset ($ argv [1 ]) ? $ argv [1 ] : '127.0.0.1:8080 ' ;
24+ $ url = getenv ('http_proxy ' );
25+ if ($ url === false ) {
26+ $ url = '127.0.0.1:8080 ' ;
27+ }
2228
2329$ loop = React \EventLoop \Factory::create ();
2430
Original file line number Diff line number Diff line change 99//
1010// $ php examples/22-proxy-raw-smtps-protocol.php
1111//
12- // The proxy can be given as first argument and defaults to localhost:8080 otherwise.
12+ // If you want to run the same example with any other proxy URL, just use:
13+ //
14+ // $ http_proxy=127.0.0.1.8181 php examples/22-proxy-raw-smtps-protocol.php
15+ //
1316// This example highlights how changing from plain connections (see previous
1417// example) to using a secure connection actually adds very little complexity
1518// and does not mess with your actual network protocol otherwise.
2124
2225require __DIR__ . '/../vendor/autoload.php ' ;
2326
24- $ url = isset ($ argv [1 ]) ? $ argv [1 ] : '127.0.0.1:8080 ' ;
27+ $ url = getenv ('http_proxy ' );
28+ if ($ url === false ) {
29+ $ url = '127.0.0.1:8080 ' ;
30+ }
2531
2632$ loop = React \EventLoop \Factory::create ();
2733
You can’t perform that action at this time.
0 commit comments