createFromLoopConnectors() public static méthode

create sender attached to given event loop using the given connectors
public static createFromLoopConnectors ( React\EventLoop\LoopInterface $loop, React\SocketClient\ConnectorInterface $connector, React\SocketClient\ConnectorInterface $secureConnector = null ) : self
$loop React\EventLoop\LoopInterface
$connector React\SocketClient\ConnectorInterface default connector to use to establish TCP/IP connections
$secureConnector React\SocketClient\ConnectorInterface secure connector to use to establish TLS/SSL connections (optional, composed from given default connector)
Résultat self
Exemple #1
0
 public function testSenderRejection()
 {
     $connector = $this->getMock('React\\SocketClient\\ConnectorInterface');
     $connector->expects($this->once())->method('create')->willReturn(Promise\reject(new RuntimeException('Rejected')));
     $sender = Sender::createFromLoopConnectors($this->loop, $connector);
     $request = new Request('GET', 'http://www.google.com/');
     $promise = $sender->send($request, $this->getMock('Clue\\React\\Buzz\\Message\\MessageFactory'));
     $this->setExpectedException('RuntimeException');
     Block\await($promise, $this->loop);
 }
 public function testVerifyPeerDisabledForBadSslResolves()
 {
     if (!function_exists('stream_socket_enable_crypto')) {
         $this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
     }
     if (!class_exists('React\\SocketClient\\TcpConnector')) {
         $this->markTestSkipped('Test requires SocketClient:0.5');
     }
     $dnsResolverFactory = new DnsFactory();
     $resolver = $dnsResolverFactory->createCached('8.8.8.8', $this->loop);
     $tcp = new DnsConnector(new TcpConnector($this->loop), $resolver);
     $ssl = new SecureConnector($tcp, $this->loop, array('verify_peer' => false));
     $sender = Sender::createFromLoopConnectors($this->loop, $tcp, $ssl);
     $browser = $this->browser->withSender($sender);
     Block\await($browser->get('https://self-signed.badssl.com/'), $this->loop);
 }
Exemple #3
0
<?php

use Clue\React\Buzz\Io\Sender;
use React\SocketClient\TcpConnector;
use React\EventLoop\Factory as LoopFactory;
use Clue\React\Socks\Client as SocksClient;
use Clue\React\Buzz\Browser;
use Psr\Http\Message\ResponseInterface;
use RingCentral\Psr7;
require __DIR__ . '/vendor/autoload.php';
$loop = LoopFactory::create();
// create a new SOCKS client which connects to a SOCKS server listening on localhost:9050
// not already running a SOCKS server? Try this: ssh -D 9050 localhost
$socks = new SocksClient('127.0.0.1:9050', new TcpConnector($loop));
// create a Browser object that uses the SOCKS client for connections
$sender = Sender::createFromLoopConnectors($loop, $socks);
$browser = new Browser($loop, $sender);
// demo fetching HTTP headers (or bail out otherwise)
$browser->get('https://www.google.com/')->then(function (ResponseInterface $response) {
    echo Psr7\str($response);
}, 'printf');
$loop->run();