本文整理汇总了PHP中Google_HttpRequest::setRequestMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_HttpRequest::setRequestMethod方法的具体用法?PHP Google_HttpRequest::setRequestMethod怎么用?PHP Google_HttpRequest::setRequestMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google_HttpRequest
的用法示例。
在下文中一共展示了Google_HttpRequest::setRequestMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProcessEntityRequest
public function testProcessEntityRequest()
{
$io = new Google_CurlIO();
$req = new Google_HttpRequest("http://localhost.com");
$req->setRequestMethod("POST");
// Verify that the content-length is calculated.
$req->setPostBody("{}");
$io->processEntityRequest($req);
$this->assertEquals(2, $req->getRequestHeader("content-length"));
// Test an empty post body.
$req->setPostBody("");
$io->processEntityRequest($req);
$this->assertEquals(0, $req->getRequestHeader("content-length"));
// Test a null post body.
$req->setPostBody(null);
$io->processEntityRequest($req);
$this->assertEquals(0, $req->getRequestHeader("content-length"));
// Set an array in the postbody, and verify that it is url-encoded.
$req->setPostBody(array("a" => "1", "b" => 2));
$io->processEntityRequest($req);
$this->assertEquals(7, $req->getRequestHeader("content-length"));
$this->assertEquals(Google_CurlIO::FORM_URLENCODED, $req->getRequestHeader("content-type"));
$this->assertEquals("a=1&b=2", $req->getPostBody());
// Verify that the content-type isn't reset.
$payload = array("a" => "1", "b" => 2);
$req->setPostBody($payload);
$req->setRequestHeaders(array("content-type" => "multipart/form-data"));
$io->processEntityRequest($req);
$this->assertEquals("multipart/form-data", $req->getRequestHeader("content-type"));
$this->assertEquals($payload, $req->getPostBody());
}