本文整理汇总了PHP中Guzzle\Http\Message\Request::setResponseBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::setResponseBody方法的具体用法?PHP Request::setResponseBody怎么用?PHP Request::setResponseBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Request
的用法示例。
在下文中一共展示了Request::setResponseBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanSignRequest
/**
* @covers PusherSignature::signRequest
*/
public function testCanSignRequest()
{
$request = new HttpRequest('POST', '/apps/3/events');
// We set variables in query to have always the same result
$request->getQuery()->replace(array('auth_key' => $this->credentials->getKey(), 'auth_timestamp' => '1353088179', 'auth_version' => '1.0', 'body_md5' => 'ec365a775a4cd0599faeb73354201b6f'));
$request->setResponseBody('{"name":"foo","channels":["project-3"],"data":"{\\"some\\":\\"data\\"}"}');
$this->pusherSignature->signRequest($request, $this->credentials);
$this->assertEquals('auth_key=278d425bdf160c739803&auth_timestamp=1353088179&auth_version=1.0&body_md5=ec365a775a4cd0599faeb73354201b6f&auth_signature=da454824c97ba181a32ccc17a72625ba02771f50b50e1e7430e47a1f3f457e6c', $request->getQuery('auth_signature'));
}
示例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());
}