@@ -21,11 +21,15 @@ secure HTTPS request to google.com through a local HTTP proxy server:
2121
2222``` php
2323$loop = React\EventLoop\Factory::create();
24- $connector = new TcpConnector($loop);
25- $proxy = new ProxyConnector('127.0.0.1:8080', $connector);
26- $ssl = new SecureConnector($proxy, $loop);
2724
28- $ssl->connect('google.com:443')->then(function (ConnectionInterface $stream) {
25+ $proxy = new ProxyConnector('127.0.0.1:8080', new Connector($loop));
26+ $connector = new Connector($loop, array(
27+ 'tcp' => $proxy,
28+ 'timeout' => 3.0,
29+ 'dns' => false
30+ ));
31+
32+ $connector->connect('tls://google.com:443')->then(function (ConnectionInterface $stream) {
2933 $stream->write("GET / HTTP/1.1\r\nHost: google.com\r\nConnection: close\r\n\r\n");
3034 $stream->on('data', function ($chunk) {
3135 echo $chunk;
@@ -91,15 +95,15 @@ Its constructor simply accepts an HTTP proxy URL and a connector used to connect
9195to the proxy server address:
9296
9397``` php
94- $connector = new TcpConnector ($loop);
98+ $connector = new Connector ($loop);
9599$proxy = new ProxyConnector('127.0.0.1:8080', $connector);
96100```
97101
98102The proxy URL may or may not contain a scheme and port definition. The default
99103port will be ` 80 ` for HTTP (or ` 443 ` for HTTPS), but many common HTTP proxy
100104servers use custom ports.
101105In its most simple form, the given connector will be a
102- [ ` TcpConnector ` ] ( https://github.com/reactphp/socket#tcpconnector ) if you
106+ [ ` \React\Socket\Connector ` ] ( https://github.com/reactphp/socket#connector ) if you
103107want to connect to a given IP address as above.
104108
105109This is the main class in this package.
@@ -121,7 +125,7 @@ connector is actually inherently a general-purpose plain TCP/IP connector:
121125``` php
122126$proxy = new ProxyConnector('127.0.0.1:8080', $connector);
123127
124- $proxy->connect('smtp.googlemail.com:587')->then(function (ConnectionInterface $stream) {
128+ $proxy->connect('tcp:// smtp.googlemail.com:587')->then(function (ConnectionInterface $stream) {
125129 $stream->write("EHLO local\r\n");
126130 $stream->on('data', function ($chunk) use ($stream) {
127131 echo $chunk;
@@ -133,15 +137,18 @@ Note that HTTP CONNECT proxies often restrict which ports one may connect to.
133137Many (public) proxy servers do in fact limit this to HTTPS (443) only.
134138
135139If you want to establish a TLS connection (such as HTTPS) between you and
136- your destination, you may want to wrap this connector in a
137- [ ` SecureConnector ` ] ( https://github.com/reactphp/socket#secureconnector )
138- instance :
140+ your destination, you may want to wrap this connector in React's
141+ [ ` Connector ` ] ( https://github.com/reactphp/socket#connector ) or the low-level
142+ [ ` SecureConnector ` ] ( https://github.com/reactphp/socket#secureconnector ) :
139143
140144``` php
141145$proxy = new ProxyConnector('127.0.0.1:8080', $connector);
142- $ssl = new SecureConnector($proxy, $loop);
146+ $connector = new Connector($loop, array(
147+ 'tcp' => $proxy,
148+ 'dns' => false
149+ ));
143150
144- $ssl ->connect('smtp.googlemail.com:465')->then(function (ConnectionInterface $stream) {
151+ $connector ->connect('tls:// smtp.googlemail.com:465')->then(function (ConnectionInterface $stream) {
145152 $stream->write("EHLO local\r\n");
146153 $stream->on('data', function ($chunk) use ($stream) {
147154 echo $chunk;
0 commit comments