File tree 7 files changed +76
-7
lines changed
7 files changed +76
-7
lines changed Original file line number Diff line number Diff line change 25
25
"require-dev" : {
26
26
"phpunit/phpunit" : " ^9.0 || ^7.0 || ^5.0 || ^4.8" ,
27
27
"react/event-loop" : " ^1.0 || ^0.5 || ^0.4 || ^0.3" ,
28
+ "react/http" : " ^1.0" ,
28
29
"clue/block-react" : " ^1.1"
29
30
}
30
31
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // A simple example which uses an HTTP client to request https://example.com/ through an HTTP CONNECT proxy.
4
+ // You can use any kind of proxy, for example https://github.com/leproxy/leproxy and excecute it like this:
5
+ //
6
+ // $ php leproxy-latest.php
7
+ //
8
+ // To run the example, go to the project root and run:
9
+ //
10
+ // $ php examples/01-http-requests.php
11
+ //
12
+ // Make sure you're referencing the right proxy adress inside the ProxyConnector
13
+
14
+ use React \HTTP \Browser ;
15
+
16
+ require __DIR__ . '/../vendor/autoload.php ' ;
17
+
18
+ $ loop = React \EventLoop \Factory::create ();
19
+ $ proxy = new Clue \React \HttpProxy \ProxyConnector ('127.0.0.1:8080 ' , new React \Socket \Connector ($ loop ));
20
+
21
+ $ connector = new React \Socket \Connector ($ loop , array (
22
+ 'tcp ' => $ proxy ,
23
+ 'dns ' => false
24
+ ));
25
+
26
+ $ browser = new React \Http \Browser ($ loop , $ connector );
27
+
28
+ $ browser ->get ('https://example.com/ ' )->then (function (Psr \Http \Message \ResponseInterface $ response ) {
29
+ var_dump ($ response ->getHeaders (), (string ) $ response ->getBody ());
30
+ }, 'printf ' );
31
+
32
+ $ loop ->run ();
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
// A simple example which requests https://google.com/ through an HTTP CONNECT proxy.
4
+ // You can use any kind of proxy, for example https://github.com/leproxy/leproxy and excecute it like this:
5
+ //
6
+ // $ php leproxy-latest.php
7
+ //
8
+ // To run the example, go to the project root and run:
9
+ //
10
+ // $ php examples/11-proxy-raw-https-protocol.php
11
+ //
4
12
// The proxy can be given as first argument and defaults to localhost:8080 otherwise.
5
13
//
6
14
// For illustration purposes only. If you want to send HTTP requests in a real
7
- // world project, take a look at https://github.com/clue/reactphp-buzz#http-proxy
15
+ // world project, take a look at example-01
8
16
9
17
use Clue \React \HttpProxy \ProxyConnector ;
10
18
use React \Socket \Connector ;
Original file line number Diff line number Diff line change 2
2
3
3
// A simple example which requests https://google.com/ either directly or through
4
4
// an HTTP CONNECT proxy.
5
+ // To run the example, go to the project root and run:
6
+ //
7
+ // $ php examples/12-optional-proxy-raw-https-protocol.php
8
+ //
5
9
// The Proxy can be given as first argument or does not use a proxy otherwise.
6
10
// This example highlights how changing from direct connection to using a proxy
7
11
// actually adds very little complexity and does not mess with your actual
8
12
// network protocol otherwise.
9
13
//
10
14
// For illustration purposes only. If you want to send HTTP requests in a real
11
- // world project, take a look at https://github.com/clue/reactphp-buzz#http-proxy
15
+ // world project, take a look at example-01
12
16
13
17
use Clue \React \HttpProxy \ProxyConnector ;
14
18
use React \Socket \Connector ;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
// A simple example which requests https://google.com/ through an HTTP CONNECT proxy.
4
+ // You can use any kind of proxy, for example https://github.com/leproxy/leproxy and excecute it like this:
5
+ //
6
+ // $ php leproxy-latest.php
7
+ //
8
+ // To run the example, go to the project root and run:
9
+ //
10
+ // $ php examples/13-custom-proxy-headers.php
11
+ //
4
12
// The proxy can be given as first argument and defaults to localhost:8080 otherwise.
5
13
//
6
14
// For illustration purposes only. If you want to send HTTP requests in a real
7
- // world project, take a look at https://github.com/clue/reactphp-buzz#http-proxy
15
+ // world project, take a look at example-01
8
16
9
17
use Clue \React \HttpProxy \ProxyConnector ;
10
18
use React \Socket \Connector ;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- // A simple example which uses a plain SMTP connection to Googlemail through a HTTP CONNECT proxy.
4
- // Proxy can be given as first argument and defaults to localhost:8080 otherwise.
3
+ // A simple example which requests https://google.com/ through an HTTP CONNECT proxy.
4
+ // You can use any kind of proxy, for example https://github.com/leproxy/leproxy and excecute it like this:
5
+ //
6
+ // $ php leproxy-latest.php
7
+ //
8
+ // To run the example, go to the project root and run:
9
+ //
10
+ // $ php examples/21-proxy-raw-smtp-protocol.php
11
+ //
12
+ // The proxy can be given as first argument and defaults to localhost:8080 otherwise.
5
13
// Please note that MANY public proxies do not allow SMTP connections, YMMV.
6
14
7
15
use Clue \React \HttpProxy \ProxyConnector ;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- // A simple example which uses a secure SMTP connection to Googlemail through a HTTP CONNECT proxy.
4
- // Proxy can be given as first argument and defaults to localhost:8080 otherwise.
3
+ // A simple example which requests https://google.com/ through an HTTP CONNECT proxy.
4
+ // You can use any kind of proxy, for example https://github.com/leproxy/leproxy and excecute it like this:
5
+ //
6
+ // $ php leproxy-latest.php
7
+ //
8
+ // To run the example, go to the project root and run:
9
+ //
10
+ // $ php examples/22-proxy-raw-smtps-protocol.php
11
+ //
12
+ // The proxy can be given as first argument and defaults to localhost:8080 otherwise.
5
13
// This example highlights how changing from plain connections (see previous
6
14
// example) to using a secure connection actually adds very little complexity
7
15
// and does not mess with your actual network protocol otherwise.
You can’t perform that action at this time.
0 commit comments