File tree 6 files changed +45
-16
lines changed
6 files changed +45
-16
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.
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
14
15
15
16
require __DIR__ . '/../vendor/autoload.php ' ;
16
17
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
+ }
18
22
19
23
$ loop = React \EventLoop \Factory::create ();
20
24
$ 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
+ // 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
+ //
10
13
// This example highlights how changing from direct connection to using a proxy
11
14
// actually adds very little complexity and does not mess with your actual
12
15
// network protocol otherwise.
24
27
25
28
$ connector = new Connector ($ loop );
26
29
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 );
30
33
$ connector = new Connector ($ loop , array (
31
34
'tcp ' => $ proxy ,
32
35
'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