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


PHP Response::getProtocolVersion方法代码示例

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


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

示例1: formatProvider

 public function formatProvider()
 {
     $request = new Request('PUT', '/', ['x-test' => 'abc'], Stream::factory('foo'));
     $response = new Response(200, ['X-Baz' => 'Bar'], Stream::factory('baz'));
     $err = new RequestException('Test', $request, $response);
     return [['{request}', [$request], (string) $request], ['{response}', [$request, $response], (string) $response], ['{request} {response}', [$request, $response], $request . ' ' . $response], ['{request} {response}', [$request], $request . ' '], ['{req_headers}', [$request], "PUT / HTTP/1.1\r\nx-test: abc"], ['{res_headers}', [$request, $response], "HTTP/1.1 200 OK\r\nX-Baz: Bar"], ['{res_headers}', [$request], 'NULL'], ['{req_body}', [$request], 'foo'], ['{res_body}', [$request, $response], 'baz'], ['{res_body}', [$request], 'NULL'], ['{method}', [$request], $request->getMethod()], ['{url}', [$request], $request->getUrl()], ['{resource}', [$request], $request->getResource()], ['{req_version}', [$request], $request->getProtocolVersion()], ['{res_version}', [$request, $response], $response->getProtocolVersion()], ['{res_version}', [$request], 'NULL'], ['{host}', [$request], $request->getHost()], ['{hostname}', [$request, $response], gethostname()], ['{hostname}{hostname}', [$request, $response], gethostname() . gethostname()], ['{code}', [$request, $response], $response->getStatusCode()], ['{code}', [$request], 'NULL'], ['{phrase}', [$request, $response], $response->getReasonPhrase()], ['{phrase}', [$request], 'NULL'], ['{error}', [$request, $response, $err], 'Test'], ['{error}', [$request], 'NULL'], ['{req_header_x-test}', [$request], 'abc'], ['{req_header_x-not}', [$request], ''], ['{res_header_X-Baz}', [$request, $response], 'Bar'], ['{res_header_x-not}', [$request, $response], ''], ['{res_header_X-Baz}', [$request], 'NULL']];
 }
开发者ID:assad2012,项目名称:EvaOAuth,代码行数:7,代码来源:FormatterTest.php

示例2: testDoesTheSameAsResponseWhenDereferenced

 public function testDoesTheSameAsResponseWhenDereferenced()
 {
     $str = Stream::factory('foo');
     $response = new Response(200, ['Foo' => 'bar'], $str);
     $future = MockTest::createFuture(function () use($response) {
         return $response;
     });
     $this->assertFalse($this->readAttribute($future, 'isRealized'));
     $this->assertEquals(200, $future->getStatusCode());
     $this->assertTrue($this->readAttribute($future, 'isRealized'));
     // Deref again does nothing.
     $future->wait();
     $this->assertTrue($this->readAttribute($future, 'isRealized'));
     $this->assertEquals('bar', $future->getHeader('Foo'));
     $this->assertEquals(['bar'], $future->getHeaderAsarray('Foo'));
     $this->assertSame($response->getHeaders(), $future->getHeaders());
     $this->assertSame($response->getBody(), $future->getBody());
     $this->assertSame($response->getProtocolVersion(), $future->getProtocolVersion());
     $this->assertSame($response->getEffectiveUrl(), $future->getEffectiveUrl());
     $future->setEffectiveUrl('foo');
     $this->assertEquals('foo', $response->getEffectiveUrl());
     $this->assertSame($response->getReasonPhrase(), $future->getReasonPhrase());
     $this->assertTrue($future->hasHeader('foo'));
     $future->removeHeader('Foo');
     $this->assertFalse($future->hasHeader('foo'));
     $this->assertFalse($response->hasHeader('foo'));
     $future->setBody(Stream::factory('true'));
     $this->assertEquals('true', (string) $response->getBody());
     $this->assertTrue($future->json());
     $this->assertSame((string) $response, (string) $future);
     $future->setBody(Stream::factory('<a><b>c</b></a>'));
     $this->assertEquals('c', (string) $future->xml()->b);
     $future->addHeader('a', 'b');
     $this->assertEquals('b', $future->getHeader('a'));
     $future->addHeaders(['a' => '2']);
     $this->assertEquals('b, 2', $future->getHeader('a'));
     $future->setHeader('a', '2');
     $this->assertEquals('2', $future->getHeader('a'));
     $future->setHeaders(['a' => '3']);
     $this->assertEquals(['a' => ['3']], $future->getHeaders());
 }
开发者ID:hexcode007,项目名称:yfcms,代码行数:41,代码来源:FutureResponseTest.php


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