当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::setState方法代码示例

本文整理汇总了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;
 }
开发者ID:diandianxiyu,项目名称:Yii2Api,代码行数:8,代码来源:EntityEnclosingRequest.php

示例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'));
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:16,代码来源:BackoffPluginTest.php

示例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);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:9,代码来源:RequestTest.php


注:本文中的Guzzle\Http\Message\Request::setState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。