File tree Expand file tree Collapse file tree 6 files changed +47
-15
lines changed
Expand file tree Collapse file tree 6 files changed +47
-15
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.
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
1315use React \HTTP \Browser ;
1416
1517require __DIR__ . '/../vendor/autoload.php ' ;
1618
17- $ url = isset ($ argv [1 ]) ? $ argv [1 ] : '127.0.0.1:8080 ' ;
19+ $ url = getenv ('http_proxy ' );
20+ if ($ url === false ){
21+ $ url = '127.0.0.1:8080 ' ;
22+ }
1823
1924$ loop = React \EventLoop \Factory::create ();
2025$ 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+ // If you want to run the same example with your proxy, just use:
10+ //
11+ // $ http_proxy=127.0.0.1.8181 php examples/12-optional-proxy-raw-https-protocol.php
12+ //
13+ // The proxy URL can be given as an environment variable
1014// This example highlights how changing from direct connection to using a proxy
1115// actually adds very little complexity and does not mess with your actual
1216// network protocol otherwise.
2428
2529$ connector = new Connector ($ loop );
2630
27- // first argument given? use this as the proxy URL
28- if (isset ($ argv [1 ])) {
29- $ proxy = new ProxyConnector ($ argv [1 ], $ connector );
31+ //Define environment variable with your proxy URL
32+ $ url = getenv ('http_proxy ' );
33+ if ($ url !== false ) {
34+ $ proxy = new ProxyConnector ($ url , $ connector );
3035 $ connector = new Connector ($ loop , array (
3136 'tcp ' => $ proxy ,
3237 '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