Skip to content

Replace deprecated SocketClient with new Socket component #9

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

Merged
merged 2 commits into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Replace deprecated SocketClient with new Socket component
  • Loading branch information
clue committed Apr 10, 2017
commit 126810b2f165c863ff491314c093ef9aa7ee2f9d
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ establishing streaming connections, such as a normal TCP/IP connection.
In order to use this library, you should understand how this integrates with its
ecosystem.
This base interface is actually defined in React's
[SocketClient component](https://github.com/reactphp/socket-client) and used
[Socket component](https://github.com/reactphp/socket) and used
throughout React's ecosystem.

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

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

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

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

```php
Expand All @@ -156,7 +156,7 @@ destination host as above.

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

```php
Expand Down Expand Up @@ -206,7 +206,7 @@ MIT
* If you want to learn more about how the
[`ConnectorInterface`](#connectorinterface) and its usual implementations look
like, refer to the documentation of the underlying
[react/socket-client](https://github.com/reactphp/socket-client) component.
[react/socket](https://github.com/reactphp/socket) component.
* As an alternative to an HTTP CONNECT proxy, you may also want to look into
using a SOCKS (SOCKS4/SOCKS5) proxy instead.
You may want to use [clue/socks-react](https://github.com/clue/php-socks-react)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require": {
"php": ">=5.3",
"react/socket-client": "^0.7 || ^0.6",
"react/socket": "^0.7",
"react/event-loop": "^0.4 || ^0.3",
"react/promise": " ^2.1 || ^1.2",
"ringcentral/psr7": "^1.2"
Expand Down
6 changes: 3 additions & 3 deletions examples/01-proxy-https.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// The proxy can be given as first argument and defaults to localhost:8080 otherwise.

use Clue\React\HttpProxy\ProxyConnector;
use React\SocketClient\TcpConnector;
use React\SocketClient\SecureConnector;
use React\SocketClient\ConnectionInterface;
use React\Socket\TcpConnector;
use React\Socket\SecureConnector;
use React\Socket\ConnectionInterface;

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

Expand Down
8 changes: 4 additions & 4 deletions examples/02-optional-proxy-https.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// network protocol otherwise.

use Clue\React\HttpProxy\ProxyConnector;
use React\SocketClient\TcpConnector;
use React\SocketClient\SecureConnector;
use React\SocketClient\DnsConnector;
use React\Socket\TcpConnector;
use React\Socket\SecureConnector;
use React\Socket\DnsConnector;
use React\Dns\Resolver\Factory;
use React\SocketClient\ConnectionInterface;
use React\Socket\ConnectionInterface;

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

Expand Down
4 changes: 2 additions & 2 deletions examples/11-proxy-smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Please note that MANY public proxies do not allow SMTP connections, YMMV.

use Clue\React\HttpProxy\ProxyConnector;
use React\SocketClient\TcpConnector;
use React\SocketClient\ConnectionInterface;
use React\Socket\TcpConnector;
use React\Socket\ConnectionInterface;

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

Expand Down
6 changes: 3 additions & 3 deletions examples/12-proxy-smtps.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// Please note that MANY public proxies do not allow SMTP connections, YMMV.

use Clue\React\HttpProxy\ProxyConnector;
use React\SocketClient\TcpConnector;
use React\SocketClient\SecureConnector;
use React\SocketClient\ConnectionInterface;
use React\Socket\TcpConnector;
use React\Socket\SecureConnector;
use React\Socket\ConnectionInterface;

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

Expand Down
4 changes: 2 additions & 2 deletions src/ProxyConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Clue\React\HttpProxy;

use React\SocketClient\ConnectorInterface;
use React\Socket\ConnectorInterface;
use Exception;
use InvalidArgumentException;
use RuntimeException;
use RingCentral\Psr7;
use React\Promise\Deferred;
use React\SocketClient\ConnectionInterface;
use React\Socket\ConnectionInterface;

/**
* A simple Connector that uses an HTTP CONNECT proxy to create plain TCP/IP connections to any destination
Expand Down
6 changes: 3 additions & 3 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use React\EventLoop\Factory;
use Clue\React\HttpProxy\ProxyConnector;
use React\SocketClient\TcpConnector;
use React\SocketClient\DnsConnector;
use React\Socket\TcpConnector;
use React\Socket\DnsConnector;
use Clue\React\Block;
use React\SocketClient\SecureConnector;
use React\Socket\SecureConnector;

class FunctionalTest extends AbstractTestCase
{
Expand Down
18 changes: 9 additions & 9 deletions tests/ProxyConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

use Clue\React\HttpProxy\ProxyConnector;
use React\Promise\Promise;
use React\SocketClient\ConnectionInterface;
use React\Socket\ConnectionInterface;

class ProxyConnectorTest extends AbstractTestCase
{
private $connector;

public function setUp()
{
$this->connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
}

/**
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testCancelPromiseWillCancelPendingConnection()

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

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

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

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

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

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

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

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

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

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

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

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

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

$promise = \React\Promise\resolve($stream);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy