本文整理汇总了PHP中Guzzle\Http\Message\Request::setState方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::setState方法的具体用法?PHP Request::setState怎么用?PHP Request::setState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Request
的用法示例。
在下文中一共展示了Request::setState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setState
public function setState($state, array $context = array())
{
parent::setState($state, $context);
if ($state == self::STATE_TRANSFER && !$this->body && !count($this->postFields) && !count($this->postFiles)) {
$this->setHeader('Content-Length', 0)->removeHeader('Transfer-Encoding');
}
return $this->state;
}
示例2: testUpdatesRequestForRetry
public function testUpdatesRequestForRetry()
{
$request = new Request('GET', 'http://www.example.com');
$request->setState('transfer');
$response = new Response(500);
$handle = $this->getMockBuilder('Guzzle\\Http\\Curl\\CurlHandle')->disableOriginalConstructor()->getMock();
$e = new CurlException();
$e->setCurlHandle($handle);
$plugin = new BackoffPlugin(new ConstantBackoffStrategy(10));
$plugin->addSubscriber($this);
$event = new Event(array('request' => $request, 'response' => $response, 'exception' => $e));
$plugin->onRequestSent($event);
$this->assertEquals(array('request' => $request, 'response' => $response, 'handle' => $handle, 'retries' => 1, 'delay' => 10), $this->readAttribute($this->retried, 'context'));
$plugin->onRequestSent($event);
$this->assertEquals(array('request' => $request, 'response' => $response, 'handle' => $handle, 'retries' => 2, 'delay' => 10), $this->readAttribute($this->retried, 'context'));
}
示例3: testRequestThrowsExceptionWhenSetToCompleteWithNoResponse
/**
* @covers Guzzle\Http\Message\Request::processResponse
* @expectedException Guzzle\Http\Exception\RequestException
* @expectedExceptionMessage Error completing request
*/
public function testRequestThrowsExceptionWhenSetToCompleteWithNoResponse()
{
$this->request->setState(RequestInterface::STATE_COMPLETE);
}