本文整理汇总了PHP中GuzzleHttp\Message\Response::hasHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::hasHeader方法的具体用法?PHP Response::hasHeader怎么用?PHP Response::hasHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\Response
的用法示例。
在下文中一共展示了Response::hasHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}