Skip to content

Commit 60fa846

Browse files
SimonFringssimon
authored andcommitted
Update to reactphp/http v1.0.0
1 parent 54f2344 commit 60fa846

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,35 @@ $connector = new React\Socket\Connector($loop, array(
272272

273273
#### HTTP requests
274274

275-
HTTP operates on a higher layer than this low-level SOCKS implementation.
276-
If you want to issue HTTP requests, you can add a dependency for
277-
[clue/reactphp-buzz](https://github.com/clue/reactphp-buzz).
278-
It can interact with this library by issuing all
279-
[HTTP requests through a SOCKS proxy server](https://github.com/clue/reactphp-buzz#socks-proxy).
280-
This works for both plain HTTP and TLS-encrypted HTTPS requests.
275+
This library also allows you to send
276+
[HTTP requests through a SOCKS proxy server](https://github.com/reactphp/http#socks-proxy).
277+
278+
In order to send HTTP requests, you first have to add a dependency for
279+
[ReactPHP's async HTTP client](https://github.com/reactphp/http#client-usage).
280+
This allows you to send both plain HTTP and TLS-encrypted HTTPS requests like this:
281+
282+
```php
283+
$proxy = new Clue\React\Socks\Client(
284+
'socks://127.0.0.1:1080',
285+
new React\Socket\Connector($loop)
286+
);
287+
288+
$connector = new React\Socket\Connector($loop, array(
289+
'tcp' => $proxy,
290+
'dns' => false
291+
));
292+
293+
$browser = new React\Http\Browser($loop, $connector);
294+
295+
$browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) {
296+
var_dump($response->getHeaders(), (string) $response->getBody());
297+
}, function (Exception $e) {
298+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
299+
});
300+
```
301+
302+
See also [ReactPHP's HTTP client](https://github.com/reactphp/http#client-usage)
303+
and any of the [examples](examples) for more details.
281304

282305
#### Protocol version
283306

0 commit comments

Comments
 (0)