Skip to content

Update README to reactphp/http v1.0.0 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down