Ejemplo n.º 1
0
 public function testReleasesAdditionalEasyHandles()
 {
     Server::flush();
     Server::enqueue(["HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"]);
     $a = new CurlAdapter(new MessageFactory(), ['max_handles' => 2]);
     $client = new Client(['base_url' => Server::$url, 'adapter' => $a]);
     $request = $client->createRequest('GET', '/', ['events' => ['headers' => function (HeadersEvent $e) use($client) {
         $client->get('/', ['events' => ['headers' => function (HeadersEvent $e) {
             $e->getClient()->get('/');
         }]]);
     }]]);
     $transaction = new Transaction($client, $request);
     $a->send($transaction);
     $this->assertCount(2, $this->readAttribute($a, 'handles'));
 }
Ejemplo n.º 2
0
 public function testRewindsStreamOnComplete()
 {
     Server::flush();
     Server::enqueue("HTTP/1.1 200 OK\r\nFoo: bar\r\nContent-Length: 4\r\n\r\ntest");
     $t = new Transaction(new Client(), new Request('GET', Server::$url));
     $a = new CurlAdapter(new MessageFactory());
     $response = $a->send($t);
     $this->assertEquals('test', $response->getBody()->read(4));
 }