本文整理汇总了PHP中Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase方法的典型用法代码示例。如果您正苦于以下问题:PHP ResponseHeaderBag::allPreserveCase方法的具体用法?PHP ResponseHeaderBag::allPreserveCase怎么用?PHP ResponseHeaderBag::allPreserveCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\ResponseHeaderBag
的用法示例。
在下文中一共展示了ResponseHeaderBag::allPreserveCase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendHeaders
/**
* Sends HTTP headers.
*
* @return Response
*/
public function sendHeaders()
{
// headers have already been sent by the developer
if (headers_sent()) {
return $this;
}
// status
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText));
// headers
foreach ($this->headers->allPreserveCase() as $name => $values) {
foreach ($values as $value) {
header($name . ': ' . $value, false);
}
}
// cookies
foreach ($this->headers->getCookies() as $cookie) {
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
}
return $this;
}
示例2: testToStringDoesntMessUpHeaders
public function testToStringDoesntMessUpHeaders()
{
$headers = new ResponseHeaderBag();
$headers->set('Location', 'http://www.symfony.com');
$headers->set('Content-type', 'text/html');
(string) $headers;
$allHeaders = $headers->allPreserveCase();
$this->assertEquals(array('http://www.symfony.com'), $allHeaders['Location']);
$this->assertEquals(array('text/html'), $allHeaders['Content-type']);
}
示例3: sendHeaders
/**
* Sends HTTP headers.
*
* @return Response
*/
public function sendHeaders()
{
// headers have already been sent by the developer
if (headers_sent()) {
return $this;
}
if (!$this->headers->has('Date')) {
$this->setDate(\DateTime::createFromFormat('U', time()));
}
// headers
foreach ($this->headers->allPreserveCase() as $name => $values) {
foreach ($values as $value) {
header($name . ': ' . $value, false, $this->statusCode);
}
}
// status
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
// cookies
foreach ($this->headers->getCookies() as $cookie) {
if ($cookie->isRaw()) {
setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
} else {
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
}
}
return $this;
}
示例4: testAllPreserveCase
/**
* @covers Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase
* @dataProvider provideAllPreserveCase
*/
public function testAllPreserveCase($headers, $expected)
{
$bag = new ResponseHeaderBag($headers);
$this->assertEquals($expected, $bag->allPreserveCase(), '->allPreserveCase() gets all input keys in original case');
}