本文整理汇总了PHP中Guzzle\Http\Message\Request::receiveResponseHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::receiveResponseHeader方法的具体用法?PHP Request::receiveResponseHeader怎么用?PHP Request::receiveResponseHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Request
的用法示例。
在下文中一共展示了Request::receiveResponseHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testReceivingShortStatusLineResponse
/**
* Many RESTful frameworks omit the text status from the header. That
* provides a response like "HTTP/1.1 200". Prevent an Undefined offset
* by checking to see how many parts of the status line are provided
* before trying to assign them.
*
* @covers Guzzle\Http\Message\Request::receiveResponseHeader
*/
public function testReceivingShortStatusLineResponse()
{
$request = new Request('GET', $this->getServer()->getUrl());
$request->receiveResponseHeader('HTTP/1.1 200');
$this->assertSame(200, $request->getResponse()->getStatusCode());
$this->assertSame('OK', $request->getResponse()->getReasonPhrase());
}
示例2: testReceivingUnsuccessfulResponseUsesOtherResponseBody
/**
* Users sometimes want to use a custom stream when receiving a response body.
* Because of the various potential for retrying failed requests, the stream
* specified by the user should only be written to in the event that a
* successful response was received. Otherwise, a new temp stream is created
* to store the body of the failed request.
*
* @covers Guzzle\Http\Message\Request::receiveResponseHeader
*/
public function testReceivingUnsuccessfulResponseUsesOtherResponseBody()
{
$request = new Request('GET', $this->getServer()->getUrl());
$body = EntityBody::factory();
$request->setResponseBody($body);
$request->receiveResponseHeader('HTTP/1.1 503 Service Unavailable');
$this->assertNotSame($body, $request->getResponse()->getBody());
}