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


PHP Request::getProtocolVersion方法代码示例

本文整理汇总了PHP中Guzzle\Http\Message\Request::getProtocolVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getProtocolVersion方法的具体用法?PHP Request::getProtocolVersion怎么用?PHP Request::getProtocolVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Http\Message\Request的用法示例。


在下文中一共展示了Request::getProtocolVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRequestHasProtocol

 /**
  * @covers Guzzle\Http\Message\Request::getProtocolVersion
  * @covers Guzzle\Http\Message\Request::setProtocolVersion
  */
 public function testRequestHasProtocol()
 {
     $this->assertEquals('1.1', $this->request->getProtocolVersion());
     $this->assertEquals($this->request, $this->request->setProtocolVersion('1.1'));
     $this->assertEquals('1.1', $this->request->getProtocolVersion());
     $this->assertEquals($this->request, $this->request->setProtocolVersion('1.0'));
     $this->assertEquals('1.0', $this->request->getProtocolVersion());
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:12,代码来源:RequestTest.php

示例2: testInjectsSatisfiableResponsesOnException

 /**
  * @dataProvider satisfiableOnErrorProvider
  */
 public function testInjectsSatisfiableResponsesOnException($cacheResponse)
 {
     $storage = $this->getMockBuilder('Guzzle\\Plugin\\Cache\\CacheStorageInterface')->setMethods(array('fetch'))->getMockForAbstractClass();
     $storage->expects($this->exactly(2))->method('fetch')->will($this->returnValue($cacheResponse));
     $plugin = new CachePlugin(array('storage' => $storage));
     $request = new Request('GET', 'http://foo.com', array('Cache-Control' => 'max-stale'));
     $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
     $plugin->onRequestException(new Event(array('request' => $request, 'response' => $request->getResponse(), 'exception' => $this->getMock('Guzzle\\Http\\Exception\\CurlException'))));
     $plugin->onRequestSent(new Event(array('request' => $request, 'response' => $response = $request->getResponse())));
     $this->assertEquals($cacheResponse->getStatusCode(), $response->getStatusCode());
     $this->assertEquals((string) $cacheResponse->getBody(), (string) $response->getBody());
     $this->assertTrue($response->hasHeader('Age'));
     if ($response->isFresh() === false) {
         $this->assertContains('110', (string) $response->getHeader('Warning'));
     }
     $this->assertSame(sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION), (string) $request->getHeader('Via'));
     $this->assertSame(sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION), (string) $response->getHeader('Via'));
     $this->assertTrue($request->getParams()->get('cache.lookup'));
     $this->assertSame('error', $request->getParams()->get('cache.hit'));
     $this->assertTrue($response->hasHeader('X-Cache-Lookup'));
     $this->assertTrue($response->hasHeader('X-Cache'));
     $this->assertEquals('HIT from GuzzleCache', (string) $response->getHeader('X-Cache-Lookup'));
     $this->assertEquals('HIT_ERROR from GuzzleCache', (string) $response->getHeader('X-Cache'));
 }
开发者ID:rahilmomin,项目名称:ci_bootstrap_3,代码行数:27,代码来源:CachePluginTest.php


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