本文整理汇总了PHP中SS_HTTPRequest::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::setBody方法的具体用法?PHP SS_HTTPRequest::setBody怎么用?PHP SS_HTTPRequest::setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPRequest
的用法示例。
在下文中一共展示了SS_HTTPRequest::setBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIndex
public function testIndex()
{
$logger = $this->getMock('Psr\\Log\\LoggerInterface');
$logger->expects($this->once())->method('info');
$controller = new Controller($logger);
$prop = new \ReflectionProperty(__NAMESPACE__ . '\\Controller', 'response');
$prop->setAccessible(true);
$prop->setValue($controller, new \SS_HTTPResponse());
$req = new \SS_HTTPRequest('GET', '/');
$req->setBody(<<<JSON
{
"csp-report": {
"document-uri": "http://example.com/signup.html",
"referrer": "",
"blocked-uri": "http://example.com/css/style.css",
"violated-directive": "style-src cdn.example.com",
"original-policy": "default-src 'none'; style-src cdn.example.com; report-uri /_/csp-reports"
}
}
JSON
);
$response = $controller->index($req);
$this->assertEquals(204, $response->getStatusCode());
$this->assertEquals('', $response->getBody());
}
示例2: genRequest
protected function genRequest($accept = null, $body = '')
{
$req = new SS_HTTPRequest('POST', '/');
if ($accept) {
$req->addHeader('Content-Type', $accept);
}
if ($body) {
$req->setBody($body);
}
return $req;
}