コード例 #1
0
 /**
  * @covers Guzzle\Http\Curl\CurlMulti::reset
  */
 public function testsResetRemovesRequestsAndResetsState()
 {
     $request1 = new Request('GET', 'http://www.google.com/');
     $this->multi->add($request1);
     $this->multi->reset();
     $this->assertEquals(array(), $this->multi->all());
     $this->assertEquals('idle', $this->multi->getState());
 }
コード例 #2
0
 /**
  * @covers Guzzle\Http\Curl\CurlMulti::reset
  */
 public function testHardResetReopensMultiHandle()
 {
     $this->getServer()->enqueue(array("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"));
     $client = new Client($this->getServer()->getUrl());
     $message = '';
     $plugin = new LogPlugin(new ClosureLogAdapter(function ($msg) use(&$message) {
         $message .= $msg . "\n";
     }), LogPlugin::LOG_VERBOSE);
     $client->getEventDispatcher()->addSubscriber($plugin);
     $request = $client->get();
     $multi = new CurlMulti();
     $multi->add($request);
     $multi->send();
     $multi->reset(true);
     $multi->add($request);
     $multi->send();
     $this->assertNotContains('Re-using existing connection', $message);
 }
コード例 #3
0
 public function testHardResetReopensMultiHandle()
 {
     $this->getServer()->enqueue(array("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"));
     $stream = fopen('php://temp', 'w+');
     $client = new Client($this->getServer()->getUrl());
     $client->getConfig()->set('curl.CURLOPT_VERBOSE', true)->set('curl.CURLOPT_STDERR', $stream);
     $request = $client->get();
     $multi = new CurlMulti();
     $multi->add($request);
     $multi->send();
     $multi->reset(true);
     $multi->add($request);
     $multi->send();
     rewind($stream);
     $this->assertNotContains('Re-using existing connection', stream_get_contents($stream));
 }