File tree 6 files changed +47
-15
lines changed
6 files changed +47
-15
lines changed Original file line number Diff line number Diff line change 5
5
//
6
6
// $ php leproxy-latest.php
7
7
//
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:
9
9
//
10
10
// $ php examples/01-http-requests.php
11
11
//
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
13
15
use React \HTTP \Browser ;
14
16
15
17
require __DIR__ . '/../vendor/autoload.php ' ;
16
18
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
+ }
18
23
19
24
$ loop = React \EventLoop \Factory::create ();
20
25
$ proxy = new Clue \React \HttpProxy \ProxyConnector ($ url , new React \Socket \Connector ($ loop ));
Original file line number Diff line number Diff line change 9
9
//
10
10
// $ php examples/11-proxy-raw-https-protocol.php
11
11
//
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
13
15
//
14
16
// For illustration purposes only. If you want to send HTTP requests in a real
15
17
// world project, take a look at example #01 and https://github.com/reactphp/http#client-usage.
20
22
21
23
require __DIR__ . '/../vendor/autoload.php ' ;
22
24
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
+ }
24
29
25
30
$ loop = React \EventLoop \Factory::create ();
26
31
Original file line number Diff line number Diff line change 6
6
//
7
7
// $ php examples/12-optional-proxy-raw-https-protocol.php
8
8
//
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
10
14
// This example highlights how changing from direct connection to using a proxy
11
15
// actually adds very little complexity and does not mess with your actual
12
16
// network protocol otherwise.
24
28
25
29
$ connector = new Connector ($ loop );
26
30
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 );
30
35
$ connector = new Connector ($ loop , array (
31
36
'tcp ' => $ proxy ,
32
37
'timeout ' => 3.0 ,
Original file line number Diff line number Diff line change 9
9
//
10
10
// $ php examples/13-custom-proxy-headers.php
11
11
//
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
13
15
//
14
16
// For illustration purposes only. If you want to send HTTP requests in a real
15
17
// world project, take a look at example #01 and https://github.com/reactphp/http#client-usage.
20
22
21
23
require __DIR__ . '/../vendor/autoload.php ' ;
22
24
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
+ }
24
29
25
30
$ loop = React \EventLoop \Factory::create ();
26
31
Original file line number Diff line number Diff line change 9
9
//
10
10
// $ php examples/21-proxy-raw-smtp-protocol.php
11
11
//
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
+
13
16
// Please note that MANY public proxies do not allow SMTP connections, YMMV.
14
17
15
18
use Clue \React \HttpProxy \ProxyConnector ;
18
21
19
22
require __DIR__ . '/../vendor/autoload.php ' ;
20
23
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
+ }
22
28
23
29
$ loop = React \EventLoop \Factory::create ();
24
30
Original file line number Diff line number Diff line change 9
9
//
10
10
// $ php examples/22-proxy-raw-smtps-protocol.php
11
11
//
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
+
13
16
// This example highlights how changing from plain connections (see previous
14
17
// example) to using a secure connection actually adds very little complexity
15
18
// and does not mess with your actual network protocol otherwise.
21
24
22
25
require __DIR__ . '/../vendor/autoload.php ' ;
23
26
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
+ }
25
31
26
32
$ loop = React \EventLoop \Factory::create ();
27
33
You can’t perform that action at this time.
0 commit comments