Skip to content

Commit a14d79e

Browse files
authored
Merge pull request #9 from clue-labs/socket
Replace deprecated SocketClient with new Socket component
2 parents 6ae4fcf + 027eb71 commit a14d79e

File tree

9 files changed

+33
-33
lines changed

9 files changed

+33
-33
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ establishing streaming connections, such as a normal TCP/IP connection.
4747
In order to use this library, you should understand how this integrates with its
4848
ecosystem.
4949
This base interface is actually defined in React's
50-
[SocketClient component](https://github.com/reactphp/socket-client) and used
50+
[Socket component](https://github.com/reactphp/socket) and used
5151
throughout React's ecosystem.
5252

5353
Most higher-level components (such as HTTP, database or other networking
@@ -64,7 +64,7 @@ The interface only offers a single method:
6464
The `connect(string $uri): PromiseInterface<ConnectionInterface, Exception>` method
6565
can be used to establish a streaming connection.
6666
It returns a [Promise](https://github.com/reactphp/promise) which either
67-
fulfills with a [ConnectionInterface](https://github.com/reactphp/socket-client#connectioninterface) or
67+
fulfills with a [ConnectionInterface](https://github.com/reactphp/socket#connectioninterface) or
6868
rejects with an `Exception`:
6969

7070
```php
@@ -99,7 +99,7 @@ The proxy URL may or may not contain a scheme and port definition. The default
9999
port will be `80` for HTTP (or `443` for HTTPS), but many common HTTP proxy
100100
servers use custom ports.
101101
In its most simple form, the given connector will be a
102-
[`TcpConnector`](https://github.com/reactphp/socket-client#tcpconnector) if you
102+
[`TcpConnector`](https://github.com/reactphp/socket#tcpconnector) if you
103103
want to connect to a given IP address as above.
104104

105105
This is the main class in this package.
@@ -134,7 +134,7 @@ Many (public) proxy servers do in fact limit this to HTTPS (443) only.
134134

135135
If you want to establish a TLS connection (such as HTTPS) between you and
136136
your destination, you may want to wrap this connector in a
137-
[`SecureConnector`](https://github.com/reactphp/socket-client#secureconnector)
137+
[`SecureConnector`](https://github.com/reactphp/socket#secureconnector)
138138
instance:
139139

140140
```php
@@ -156,7 +156,7 @@ destination host as above.
156156

157157
If you want to connect to a (rather rare) HTTPS proxy, you may want use its
158158
HTTPS port (443) and use a
159-
[`SecureConnector`](https://github.com/reactphp/socket-client#secureconnector)
159+
[`SecureConnector`](https://github.com/reactphp/socket#secureconnector)
160160
instance to create a secure connection to the proxy:
161161

162162
```php
@@ -206,7 +206,7 @@ MIT
206206
* If you want to learn more about how the
207207
[`ConnectorInterface`](#connectorinterface) and its usual implementations look
208208
like, refer to the documentation of the underlying
209-
[react/socket-client](https://github.com/reactphp/socket-client) component.
209+
[react/socket](https://github.com/reactphp/socket) component.
210210
* As an alternative to an HTTP CONNECT proxy, you may also want to look into
211211
using a SOCKS (SOCKS4/SOCKS5) proxy instead.
212212
You may want to use [clue/socks-react](https://github.com/clue/php-socks-react)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"require": {
2020
"php": ">=5.3",
21-
"react/socket-client": "^0.7 || ^0.6",
21+
"react/socket": "^0.7.1",
2222
"react/event-loop": "^0.4 || ^0.3",
2323
"react/promise": " ^2.1 || ^1.2",
2424
"ringcentral/psr7": "^1.2"

examples/01-proxy-https.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// The proxy can be given as first argument and defaults to localhost:8080 otherwise.
55

66
use Clue\React\HttpProxy\ProxyConnector;
7-
use React\SocketClient\TcpConnector;
8-
use React\SocketClient\SecureConnector;
9-
use React\SocketClient\ConnectionInterface;
7+
use React\Socket\TcpConnector;
8+
use React\Socket\SecureConnector;
9+
use React\Socket\ConnectionInterface;
1010

1111
require __DIR__ . '/../vendor/autoload.php';
1212

examples/02-optional-proxy-https.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// network protocol otherwise.
99

1010
use Clue\React\HttpProxy\ProxyConnector;
11-
use React\SocketClient\TcpConnector;
12-
use React\SocketClient\SecureConnector;
13-
use React\SocketClient\DnsConnector;
11+
use React\Socket\TcpConnector;
12+
use React\Socket\SecureConnector;
13+
use React\Socket\DnsConnector;
1414
use React\Dns\Resolver\Factory;
15-
use React\SocketClient\ConnectionInterface;
15+
use React\Socket\ConnectionInterface;
1616

1717
require __DIR__ . '/../vendor/autoload.php';
1818

examples/11-proxy-smtp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Please note that MANY public proxies do not allow SMTP connections, YMMV.
66

77
use Clue\React\HttpProxy\ProxyConnector;
8-
use React\SocketClient\TcpConnector;
9-
use React\SocketClient\ConnectionInterface;
8+
use React\Socket\TcpConnector;
9+
use React\Socket\ConnectionInterface;
1010

1111
require __DIR__ . '/../vendor/autoload.php';
1212

examples/12-proxy-smtps.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// Please note that MANY public proxies do not allow SMTP connections, YMMV.
99

1010
use Clue\React\HttpProxy\ProxyConnector;
11-
use React\SocketClient\TcpConnector;
12-
use React\SocketClient\SecureConnector;
13-
use React\SocketClient\ConnectionInterface;
11+
use React\Socket\TcpConnector;
12+
use React\Socket\SecureConnector;
13+
use React\Socket\ConnectionInterface;
1414

1515
require __DIR__ . '/../vendor/autoload.php';
1616

src/ProxyConnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Clue\React\HttpProxy;
44

5-
use React\SocketClient\ConnectorInterface;
5+
use React\Socket\ConnectorInterface;
66
use Exception;
77
use InvalidArgumentException;
88
use RuntimeException;
99
use RingCentral\Psr7;
1010
use React\Promise\Deferred;
11-
use React\SocketClient\ConnectionInterface;
11+
use React\Socket\ConnectionInterface;
1212

1313
/**
1414
* A simple Connector that uses an HTTP CONNECT proxy to create plain TCP/IP connections to any destination

tests/FunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use React\EventLoop\Factory;
66
use Clue\React\HttpProxy\ProxyConnector;
7-
use React\SocketClient\TcpConnector;
8-
use React\SocketClient\DnsConnector;
7+
use React\Socket\TcpConnector;
8+
use React\Socket\DnsConnector;
99
use Clue\React\Block;
10-
use React\SocketClient\SecureConnector;
10+
use React\Socket\SecureConnector;
1111

1212
class FunctionalTest extends AbstractTestCase
1313
{

tests/ProxyConnectorTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
use Clue\React\HttpProxy\ProxyConnector;
66
use React\Promise\Promise;
7-
use React\SocketClient\ConnectionInterface;
7+
use React\Socket\ConnectionInterface;
88

99
class ProxyConnectorTest extends AbstractTestCase
1010
{
1111
private $connector;
1212

1313
public function setUp()
1414
{
15-
$this->connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
15+
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
1616
}
1717

1818
/**
@@ -69,7 +69,7 @@ public function testCancelPromiseWillCancelPendingConnection()
6969

7070
public function testWillWriteToOpenConnection()
7171
{
72-
$stream = $this->getMockBuilder('React\SocketClient\StreamConnection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
72+
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
7373
$stream->expects($this->once())->method('write');
7474

7575
$promise = \React\Promise\resolve($stream);
@@ -82,7 +82,7 @@ public function testWillWriteToOpenConnection()
8282

8383
public function testRejectsAndClosesIfStreamWritesNonHttp()
8484
{
85-
$stream = $this->getMockBuilder('React\SocketClient\StreamConnection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
85+
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
8686

8787
$promise = \React\Promise\resolve($stream);
8888
$this->connector->expects($this->once())->method('connect')->willReturn($promise);
@@ -99,7 +99,7 @@ public function testRejectsAndClosesIfStreamWritesNonHttp()
9999

100100
public function testRejectsAndClosesIfStreamWritesTooMuchData()
101101
{
102-
$stream = $this->getMockBuilder('React\SocketClient\StreamConnection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
102+
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
103103

104104
$promise = \React\Promise\resolve($stream);
105105
$this->connector->expects($this->once())->method('connect')->willReturn($promise);
@@ -116,7 +116,7 @@ public function testRejectsAndClosesIfStreamWritesTooMuchData()
116116

117117
public function testRejectsAndClosesIfStreamReturnsNonSuccess()
118118
{
119-
$stream = $this->getMockBuilder('React\SocketClient\StreamConnection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
119+
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
120120

121121
$promise = \React\Promise\resolve($stream);
122122
$this->connector->expects($this->once())->method('connect')->willReturn($promise);
@@ -133,7 +133,7 @@ public function testRejectsAndClosesIfStreamReturnsNonSuccess()
133133

134134
public function testResolvesIfStreamReturnsSuccess()
135135
{
136-
$stream = $this->getMockBuilder('React\SocketClient\StreamConnection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
136+
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
137137

138138
$promise = \React\Promise\resolve($stream);
139139
$this->connector->expects($this->once())->method('connect')->willReturn($promise);
@@ -153,7 +153,7 @@ public function testResolvesIfStreamReturnsSuccess()
153153

154154
public function testResolvesIfStreamReturnsSuccessAndEmitsExcessiveData()
155155
{
156-
$stream = $this->getMockBuilder('React\SocketClient\StreamConnection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
156+
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
157157

158158
$promise = \React\Promise\resolve($stream);
159159
$this->connector->expects($this->once())->method('connect')->willReturn($promise);
@@ -172,7 +172,7 @@ public function testResolvesIfStreamReturnsSuccessAndEmitsExcessiveData()
172172

173173
public function testCancelPromiseWillCloseOpenConnectionAndReject()
174174
{
175-
$stream = $this->getMockBuilder('React\SocketClient\StreamConnection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
175+
$stream = $this->getMockBuilder('React\Socket\Connection')->disableOriginalConstructor()->setMethods(array('close', 'write'))->getMock();
176176
$stream->expects($this->once())->method('close');
177177

178178
$promise = \React\Promise\resolve($stream);

0 commit comments

Comments
 (0)