From ea028b2e50bfc492b7f6231e2ba7b927988c3e09 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Thu, 30 Jul 2020 12:28:06 +0200 Subject: [PATCH] Update to reactphp/http v1.0.0 --- README.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 43d8126..81ae67f 100644 --- a/README.md +++ b/README.md @@ -315,14 +315,25 @@ $connector->connect('tls://smtp.googlemail.com:465')->then(function (ConnectionI ### HTTP requests -HTTP operates on a higher layer than this low-level SSH proxy 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 an SSH proxy server](https://github.com/clue/reactphp-buzz#ssh-proxy). -When using the `SshSocksConnector` (recommended), this works for both plain HTTP -and TLS-encrypted HTTPS requests. When using the `SshProcessConnector`, this only -works for plaintext HTTP requests. +This library also allows you to send HTTP requests through an SSH proxy server (SSH tunnel). + +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). You can then use this HTTP client in combination with the [`SshSocksConnector`](#sshsocksconnector) provided by this package. This allows you to send both plain HTTP and TLS-encrypted HTTPS requests like this: + +```php +$proxy = new Clue\React\SshProxy\SshSocksConnector('me@localhost:22', $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()); +}); +``` +For more details look into [HTTP's Client Usage](https://github.com/reactphp/http#client-usage). ### Database tunnel