本文整理汇总了PHP中HTTP_Request2::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Request2::getHeaders方法的具体用法?PHP HTTP_Request2::getHeaders怎么用?PHP HTTP_Request2::getHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP_Request2
的用法示例。
在下文中一共展示了HTTP_Request2::getHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpload
public function testUpload()
{
$req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST);
$req->addUpload('upload', dirname(__FILE__) . '/_files/plaintext.txt');
$headers = $req->getHeaders();
$this->assertEquals('multipart/form-data', $headers['content-type']);
try {
$req->addUpload('upload_2', 'missing file');
} catch (HTTP_Request2_Exception $e) {
return;
}
$this->fail('Expected HTTP_Request2_Exception was not thrown');
}
示例2: testAddCookieToJar
public function testAddCookieToJar()
{
$req = new HTTP_Request2();
$req->setCookieJar();
try {
$req->addCookie('foo', 'bar');
$this->fail('Expected HTTP_Request2_Exception was not thrown');
} catch (HTTP_Request2_LogicException $e) {
}
$req->setUrl('http://example.com/path/file.php');
$req->addCookie('foo', 'bar');
$this->assertArrayNotHasKey('cookie', $req->getHeaders());
$cookies = $req->getCookieJar()->getAll();
$this->assertEquals(array('name' => 'foo', 'value' => 'bar', 'domain' => 'example.com', 'path' => '/path/', 'expires' => null, 'secure' => false), $cookies[0]);
}
示例3: getHeaders
/**
* Gets request's headers. The returned array key (header names) are all in
* lower case even if they were set having some upper letters.
*
* @return array
*/
public function getHeaders()
{
return $this->_request->getHeaders();
}
示例4: sendRequest
public function sendRequest(HTTP_Request2 $request)
{
$this->requests[] = array('config' => $request->getConfig(), 'url' => $request->getUrl(), 'method' => $request->getMethod(), 'headers' => $request->getHeaders(), 'auth' => $request->getAuth(), 'body' => (string) $request->getBody());
return parent::sendRequest($request);
}