Skip to content

Commit d67727d

Browse files
SimonFringssimon
authored andcommitted
Update to reactphp/http v1.0.0
1 parent 9ef7e53 commit d67727d

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,33 @@ $connector->connect('tls://smtp.googlemail.com:465')->then(function (ConnectionI
315315

316316
### HTTP requests
317317

318-
HTTP operates on a higher layer than this low-level SSH proxy implementation.
319-
If you want to issue HTTP requests, you can add a dependency for
320-
[clue/reactphp-buzz](https://github.com/clue/reactphp-buzz).
321-
It can interact with this library by issuing all
322-
[HTTP requests through an SSH proxy server](https://github.com/clue/reactphp-buzz#ssh-proxy).
323-
When using the `SshSocksConnector` (recommended), this works for both plain HTTP
324-
and TLS-encrypted HTTPS requests. When using the `SshProcessConnector`, this only
325-
works for plaintext HTTP requests.
318+
This library also allows you to send
319+
[HTTP requests through an SSH proxy server](https://github.com/reactphp/http#ssh-proxy).
326320

321+
In order to send HTTP requests, you first have to add a dependency for
322+
[ReactPHP's async HTTP client](https://github.com/reactphp/http#client-usage).
323+
This allows you to send both plain HTTP and TLS-encrypted HTTPS requests like this:
324+
325+
```php
326+
$proxy = new Clue\React\SshProxy\SshSocksConnector('me@localhost:22', $loop);
327+
328+
$connector = new React\Socket\Connector($loop, array(
329+
'tcp' => $proxy,
330+
'dns' => false
331+
));
332+
333+
$browser = new React\Http\Browser($loop, $connector);
334+
335+
$browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) {
336+
var_dump($response->getHeaders(), (string) $response->getBody());
337+
}, function (Exception $e) {
338+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
339+
});
340+
```
341+
When using the `SshProcessConnector`, this only works for plaintext HTTP requests.
342+
343+
See also [ReactPHP's HTTP client](https://github.com/reactphp/http#client-usage)
344+
and any of the [examples](examples) for more details.
327345
### Database tunnel
328346

329347
We should now have a basic understanding of how we can tunnel any TCP/IP-based

0 commit comments

Comments
 (0)