本文整理汇总了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']];
}
示例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());
}