Skip to content

Commit

Permalink
Update to reactphp/http v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonFrings authored and simon committed Oct 23, 2020
1 parent 54f2344 commit 15afe1a
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,35 @@ $connector = new React\Socket\Connector($loop, array(

#### HTTP requests

HTTP operates on a higher layer than this low-level SOCKS implementation.
If you want to issue HTTP requests, you can add a dependency for
[clue/reactphp-buzz](https://github.com/clue/reactphp-buzz).
It can interact with this library by issuing all
[HTTP requests through a SOCKS proxy server](https://github.com/clue/reactphp-buzz#socks-proxy).
This works for both plain HTTP and TLS-encrypted HTTPS requests.
This library also allows you to send
[HTTP requests through a SOCKS proxy server](https://github.com/reactphp/http#socks-proxy).

In order to send HTTP requests, you first have to add a dependency for
[ReactPHP's async HTTP client](https://github.com/reactphp/http#client-usage).
This allows you to send both plain HTTP and TLS-encrypted HTTPS requests like this:

```php
$proxy = new Clue\React\Socks\Client(
'socks://127.0.0.1:1080',
new React\Socket\Connector($loop)
);

$connector = new React\Socket\Connector($loop, array(
'tcp' => $proxy,
'dns' => false
));

$browser = new React\Http\Browser($loop, $connector);

$browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) {
var_dump($response->getHeaders(), (string) $response->getBody());
}, function (Exception $error) {
var_dump('There was an error', $error->getMessage());
});
```

See also [ReactPHP's HTTP client](https://github.com/reactphp/http#client-usage)
and any of the [examples](examples) for more details.

#### Protocol version

Expand Down

0 comments on commit 15afe1a

Please sign in to comment.