diff --git a/README.md b/README.md index 1497557..bbdd49a 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,9 @@ $connector->connect('tls://smtp.googlemail.com:465')->then(function (ConnectionI This library also allows you to send HTTP requests through an HTTP CONNECT proxy server. -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: +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\HttpProxy\ProxyConnector( @@ -222,10 +224,13 @@ $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 $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); ``` -See also [ReactPHP's HTTP client](https://github.com/reactphp/http#client-usage) and any of the [examples](examples) for more details. +See also [ReactPHP's HTTP client](https://github.com/reactphp/http#client-usage) +and any of the [examples](examples) for more details. #### Connection timeout diff --git a/examples/01-http-request.php b/examples/01-http-request.php index 66bd786..90b00ef 100644 --- a/examples/01-http-request.php +++ b/examples/01-http-request.php @@ -8,11 +8,11 @@ // The proxy defaults to localhost:8080. // To run the example go to the project root and run: // -// $ php examples/01-http-requests.php +// $ php examples/01-http-request.php // // To run the same example with your proxy, the proxy URL can be given as an environment variable: // -// $ http_proxy=127.0.0.2:8080 php examples/01-http-requests.php +// $ http_proxy=127.0.0.2:8080 php examples/01-http-request.php require __DIR__ . '/../vendor/autoload.php'; @@ -33,6 +33,8 @@ $browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) { var_dump($response->getHeaders(), (string) $response->getBody()); -}, 'printf'); +}, function (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); $loop->run(); diff --git a/examples/02-optional-proxy-http-request.php b/examples/02-optional-proxy-http-request.php index 170ea7a..92a31ca 100644 --- a/examples/02-optional-proxy-http-request.php +++ b/examples/02-optional-proxy-http-request.php @@ -33,6 +33,8 @@ $browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) { var_dump($response->getHeaders(), (string) $response->getBody()); -}, 'printf'); +}, function (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); $loop->run(); diff --git a/examples/11-proxy-raw-https-protocol.php b/examples/11-proxy-raw-https-protocol.php index 873b39b..51a34bc 100644 --- a/examples/11-proxy-raw-https-protocol.php +++ b/examples/11-proxy-raw-https-protocol.php @@ -42,6 +42,8 @@ $stream->on('data', function ($chunk) { echo $chunk; }); -}, 'printf'); +}, function (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); $loop->run(); diff --git a/examples/12-optional-proxy-raw-https-protocol.php b/examples/12-optional-proxy-raw-https-protocol.php index ed206fe..fa349d0 100644 --- a/examples/12-optional-proxy-raw-https-protocol.php +++ b/examples/12-optional-proxy-raw-https-protocol.php @@ -45,6 +45,8 @@ $stream->on('data', function ($chunk) { echo $chunk; }); -}, 'printf'); +}, function (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); $loop->run(); diff --git a/examples/13-custom-proxy-headers.php b/examples/13-custom-proxy-headers.php index 09163af..cf708e1 100644 --- a/examples/13-custom-proxy-headers.php +++ b/examples/13-custom-proxy-headers.php @@ -45,6 +45,8 @@ $stream->on('data', function ($chunk) { echo $chunk; }); -}, 'printf'); +}, function (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); $loop->run(); diff --git a/examples/21-proxy-raw-smtp-protocol.php b/examples/21-proxy-raw-smtp-protocol.php index bab1605..3088b5c 100644 --- a/examples/21-proxy-raw-smtp-protocol.php +++ b/examples/21-proxy-raw-smtp-protocol.php @@ -42,6 +42,8 @@ echo $chunk; $stream->write("QUIT\r\n"); }); -}, 'printf'); +}, function (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); $loop->run(); diff --git a/examples/22-proxy-raw-smtps-protocol.php b/examples/22-proxy-raw-smtps-protocol.php index 82aa2cf..2317a95 100644 --- a/examples/22-proxy-raw-smtps-protocol.php +++ b/examples/22-proxy-raw-smtps-protocol.php @@ -45,6 +45,8 @@ echo $chunk; $stream->write("QUIT\r\n"); }); -}, 'printf'); +}, function (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; +}); $loop->run();