Skip to content

Commit c260542

Browse files
committed
Merge pull request #9 from clue/nohttp
Remove HTTP support and link to clue/buzz-react instead
2 parents 1a8b8f4 + 2ba31fc commit c260542

7 files changed

Lines changed: 19 additions & 142 deletions

File tree

README.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,12 @@ $tcp->create('www.google.com',80)->then(function (React\Stream\Stream $stream) {
4848

4949
### HTTP requests
5050

51-
Or if all you want to do is HTTP requests, `Socks/Client` provides an even simpler [HTTP client](https://github.com/reactphp/http-client) interface:
52-
```PHP
53-
$httpclient = $client->createHttpClient();
54-
55-
$request = $httpclient->request('GET', 'https://www.google.com/', array('user-agent'=>'Custom/1.0'));
56-
$request->on('response', function (React\HttpClient\Response $response) {
57-
var_dump('Headers received:', $response->getHeaders());
58-
59-
// dump whole response body
60-
$response->on('data', function ($data) {
61-
echo $data;
62-
});
63-
});
64-
$request->end();
65-
```
66-
Yes, this works for both plain HTTP and SSL encrypted HTTPS requests.
51+
HTTP operates on a higher layer than this low-level SOCKS implementation.
52+
If you want to issue HTTP requests, you can add a dependency for
53+
[clue/buzz-react](https://github.com/clue/php-buzz-react).
54+
It can interact with this library by issuing all
55+
[http requests through a SOCKS server](https://github.com/clue/php-buzz-react/#via-socks-server).
56+
This works for both plain HTTP and SSL encrypted HTTPS requests.
6757

6858
### SSL/TLS encrypted
6959

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
},
1616
"require": {
1717
"php": ">=5.3",
18-
"react/http-client": "0.3.*",
1918
"react/event-loop": "0.3.*",
2019
"react/socket-client": "0.3.*",
2120
"react/socket": "0.3.*",

composer.lock

Lines changed: 2 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/client.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
use ConnectionManager\SecureConnectionManager;
44
use React\Promise\PromiseInterface;
5-
use React\HttpClient\Client as HttpClient;
6-
use React\HttpClient\Response;
75
use React\Stream\Stream;
86

97
include_once __DIR__.'/../vendor/autoload.php';
@@ -86,20 +84,6 @@ function (Exception $error) use ($name) {
8684
// });
8785
// });
8886

89-
// $factory = new React\HttpClient\Factory();
90-
// $httpclient = $factory->create($loop, $dns);
91-
$httpclient = $client->createHttpClient();
92-
93-
$request = $httpclient->request('GET', 'https://www.google.com/', array('user-agent'=>'none'));
94-
$request->on('response', function (Response $response) {
95-
echo '[response1]' . PHP_EOL;
96-
//var_dump($response->getHeaders());
97-
$response->on('data', function ($data) {
98-
echo $data;
99-
});
100-
});
101-
$request->end();
102-
10387
$loop->addTimer(8, function() use ($loop) {
10488
$loop->stop();
10589
echo 'STOP - stopping mainloop after 8 seconds' . PHP_EOL;

src/Client.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use React\Promise\When;
66
use React\Promise\Deferred;
7-
use React\HttpClient\Client as HttpClient;
87
use React\Dns\Resolver\Resolver;
98
use React\Stream\Stream;
109
use React\EventLoop\LoopInterface;
@@ -109,11 +108,6 @@ public function unsetAuth()
109108
$this->auth = null;
110109
}
111110

112-
public function createHttpClient()
113-
{
114-
return new HttpClient($this->loop, $this->createConnector(), $this->createSecureConnector());
115-
}
116-
117111
public function createSecureConnector()
118112
{
119113
return new SecureConnector($this->createConnector(), $this->loop);

tests/ClientApiTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ public function testSetTimeout()
120120
$this->client->setTimeout(3);
121121
}
122122

123-
public function testCreateHttpClient()
124-
{
125-
$this->assertInstanceOf('\React\HttpClient\Client', $this->client->createHttpClient());
126-
}
127-
128123
public function testCreateConnector()
129124
{
130125
$this->assertInstanceOf('\React\SocketClient\ConnectorInterface', $this->client->createConnector());

tests/PairTest.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Clue\React\Socks\Factory;
4+
use React\Stream\Stream;
45

56
class PairTest extends TestCase
67
{
@@ -17,7 +18,7 @@ public function setUp()
1718
$this->factory = new Factory($this->loop, $dns);
1819
}
1920

20-
public function testClientHttpRequest()
21+
public function testClientConnection()
2122
{
2223
$socket = $this->createSocketServer();
2324
$port = $socket->getPort();
@@ -32,21 +33,15 @@ public function testClientHttpRequest()
3233

3334
$client = $this->factory->createClient('127.0.0.1', $port);
3435

35-
$http = $client->createHttpClient();
36-
37-
$request = $http->request('GET', 'https://www.google.com/', array('user-agent'=>'none'));
38-
$request->on('response', function (React\HttpClient\Response $response) {
39-
// response received, do not care for the rest of the response body
40-
$response->close();
41-
});
42-
$request->end();
43-
44-
// $loop = $this->loop;
45-
// $that = $this;
46-
// $this->loop->addTimer(1.0, function() use ($that, $loop) {
47-
// $that->fail('timeout timer');
48-
// $loop->stop();
49-
// });
36+
$that = $this;
37+
$client->getConnection('www.google.com', 80)->then(
38+
function (Stream $stream) {
39+
$stream->close();
40+
},
41+
function ($error) use ($that) {
42+
$that->fail('Unable to connect');
43+
}
44+
);
5045

5146
$this->loop->run();
5247
}

0 commit comments

Comments
 (0)