@@ -9,6 +9,9 @@ Async HTTP CONNECT proxy connector, use any TCP/IP protocol through an HTTP prox
9
9
* [ ConnectorInterface] ( #connectorinterface )
10
10
* [ connect()] ( #connect )
11
11
* [ ProxyConnector] ( #proxyconnector )
12
+ * [ Plain TCP connections] ( #plain-tcp-connections )
13
+ * [ Secure TLS connections] ( #secure-tls-connections )
14
+ * [ Advanced secure proxy connections] ( #advanced-secure-proxy-connections )
12
15
* [ Install] ( #install )
13
16
* [ Tests] ( #tests )
14
17
* [ License] ( #license )
@@ -118,9 +121,14 @@ higher-level component:
118
121
+ $client = new SomeClient($proxy);
119
122
```
120
123
124
+ #### Plain TCP connections
125
+
121
126
This is most frequently used to issue HTTPS requests to your destination.
122
127
However, this is actually performed on a higher protocol layer and this
123
- connector is actually inherently a general-purpose plain TCP/IP connector:
128
+ connector is actually inherently a general-purpose plain TCP/IP connector.
129
+
130
+ The ` ProxyConnector ` implements the [ ` ConnectorInterface ` ] ( #connectorinterface ) and
131
+ hence provides a single public method, the [ ` connect() ` ] ( #connect ) method.
124
132
125
133
``` php
126
134
$proxy = new ProxyConnector('127.0.0.1:8080', $connector);
@@ -133,9 +141,28 @@ $proxy->connect('tcp://smtp.googlemail.com:587')->then(function (ConnectionInter
133
141
});
134
142
```
135
143
144
+ You can either use the ` ProxyConnector ` directly or you may want to wrap this connector
145
+ in React's [ ` Connector ` ] ( https://github.com/reactphp/socket#connector ) :
146
+
147
+ ``` php
148
+ $connector = new Connector($loop, array(
149
+ 'tcp' => $proxy,
150
+ 'dns' => false
151
+ ));
152
+
153
+ $connector->connect('tcp://smtp.googlemail.com:587')->then(function (ConnectionInterface $stream) {
154
+ $stream->write("EHLO local\r\n");
155
+ $stream->on('data', function ($chunk) use ($stream) {
156
+ echo $chunk;
157
+ });
158
+ });
159
+ ```
160
+
136
161
Note that HTTP CONNECT proxies often restrict which ports one may connect to.
137
162
Many (public) proxy servers do in fact limit this to HTTPS (443) only.
138
163
164
+ #### Secure TLS connections
165
+
139
166
If you want to establish a TLS connection (such as HTTPS) between you and
140
167
your destination, you may want to wrap this connector in React's
141
168
[ ` Connector ` ] ( https://github.com/reactphp/socket#connector ) or the low-level
@@ -156,6 +183,11 @@ $connector->connect('tls://smtp.googlemail.com:465')->then(function (ConnectionI
156
183
});
157
184
```
158
185
186
+ > Also note how secure TLS connections are in fact entirely handled outside of
187
+ this HTTP CONNECT client implementation.
188
+
189
+ #### Advanced secure proxy connections
190
+
159
191
Note that communication between the client and the proxy is usually via an
160
192
unencrypted, plain TCP/IP HTTP connection. Note that this is the most common
161
193
setup, because you can still establish a TLS connection between you and the
0 commit comments