本文整理汇总了PHP中Symfony\Component\HttpFoundation\ServerBag::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerBag::getHeaders方法的具体用法?PHP ServerBag::getHeaders怎么用?PHP ServerBag::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\ServerBag
的用法示例。
在下文中一共展示了ServerBag::getHeaders方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHeaders
/**
* information about case sensitivity:
* @link http://stackoverflow.com/questions/7718476/are-http-headers-content-type-c-case-sensitive
* @return array
*/
private function getHeaders()
{
$headers = [];
foreach ($this->serverBag->getHeaders() as $key => $value) {
$key = str_replace(' ', '-', str_replace('_', ' ', $key));
$headers[] = '-H \'' . $key . ': ' . $value . '\'';
}
return $headers;
}
示例2: initialize
/**
* Sets the parameters for this request.
*
* This method also re-initializes all properties.
*
* @param array $query The GET parameters
* @param array $request The POST parameters
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
* @param array $cookies The COOKIE parameters
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
* @param string $content The raw body data
*
* @api
*/
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
{
$this->request = new ParameterBag($request);
$this->query = new ParameterBag($query);
$this->attributes = new ParameterBag($attributes);
$this->cookies = new ParameterBag($cookies);
$this->files = new FileBag($files);
$this->server = new ServerBag($server);
$this->headers = new HeaderBag($this->server->getHeaders());
$this->content = $content;
$this->languages = null;
$this->charsets = null;
$this->acceptableContentTypes = null;
$this->pathInfo = null;
$this->requestUri = null;
$this->baseUrl = null;
$this->basePath = null;
$this->method = null;
$this->format = null;
}
示例3: testHttpPasswordIsOptional
public function testHttpPasswordIsOptional()
{
$bag = new ServerBag(array('PHP_AUTH_USER' => 'foo'));
$this->assertEquals(array('AUTHORIZATION' => 'Basic ' . base64_encode('foo:')), $bag->getHeaders());
}
示例4: testOAuthBearerAuth
public function testOAuthBearerAuth()
{
$headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo';
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => $headerContent));
$this->assertEquals(array('AUTHORIZATION' => $headerContent), $bag->getHeaders());
}
示例5: testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet
/**
* @see https://github.com/symfony/symfony/issues/17345
*/
public function testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet()
{
$headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo';
$bag = new ServerBag(array('PHP_AUTH_USER' => 'foo', 'HTTP_AUTHORIZATION' => $headerContent));
$this->assertEquals(array('AUTHORIZATION' => $headerContent, 'PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => ''), $bag->getHeaders());
}
示例6: testHttpBasicAuthWithPhpCgiEmptyPassword
public function testHttpBasicAuthWithPhpCgiEmptyPassword()
{
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:')));
$this->assertEquals(array(
'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
'PHP_AUTH_USER' => 'foo',
'PHP_AUTH_PW' => ''
), $bag->getHeaders());
}
示例7: testShouldExtractHeadersFromServerArray
public function testShouldExtractHeadersFromServerArray()
{
$server = array('SOME_SERVER_VARIABLE' => 'value', 'SOME_SERVER_VARIABLE2' => 'value', 'ROOT' => 'value', 'HTTP_CONTENT_TYPE' => 'text/html', 'HTTP_CONTENT_LENGTH' => '0', 'HTTP_ETAG' => 'asdf');
$bag = new ServerBag($server);
$this->assertEquals(array('CONTENT_TYPE' => 'text/html', 'CONTENT_LENGTH' => '0', 'ETAG' => 'asdf'), $bag->getHeaders());
}