本文整理汇总了PHP中Guzzle\Http\Client::getCurlMulti方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getCurlMulti方法的具体用法?PHP Client::getCurlMulti怎么用?PHP Client::getCurlMulti使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Client
的用法示例。
在下文中一共展示了Client::getCurlMulti方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTrimsDownMaxHandleCount
public function testTrimsDownMaxHandleCount()
{
$this->getServer()->flush();
$this->getServer()->enqueue(array("HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 307 OK\r\nLocation: /foo\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());
$client->setCurlMulti(new CurlMultiProxy(2));
$request = $client->get();
$request->send();
$this->assertEquals(200, $request->getResponse()->getStatusCode());
$handles = $this->readAttribute($client->getCurlMulti(), 'handles');
$this->assertEquals(2, count($handles));
}
示例2: testCatchesExceptionsWhenRemovingQueuedRequestsBeforeSending
public function testCatchesExceptionsWhenRemovingQueuedRequestsBeforeSending()
{
$this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
$client = new Client($this->getServer()->getUrl());
$r = $client->get();
$r->getEventDispatcher()->addListener('request.before_send', function () use($client) {
// Create a request using a queued response
$client->get()->setResponse(new Response(404), true)->send();
});
try {
$r->send();
$this->fail('Did not throw');
} catch (BadResponseException $e) {
$this->assertCount(0, $client->getCurlMulti());
}
}
示例3: testDontReuseCurlMulti
public function testDontReuseCurlMulti()
{
$client1 = new Client();
$client2 = new Client();
$this->assertNotSame($client1->getCurlMulti(), $client2->getCurlMulti());
}