equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Component\HttpFoundation; |
|
13 |
|
14 /** |
|
15 * ServerBag is a container for HTTP headers from the $_SERVER variable. |
|
16 * |
|
17 * @author Fabien Potencier <fabien@symfony.com> |
|
18 * @author Bulat Shakirzyanov <mallluhuct@gmail.com> |
|
19 */ |
|
20 class ServerBag extends ParameterBag |
|
21 { |
|
22 public function getHeaders() |
|
23 { |
|
24 $headers = array(); |
|
25 foreach ($this->parameters as $key => $value) { |
|
26 if ('HTTP_' === substr($key, 0, 5)) { |
|
27 $headers[substr($key, 5)] = $value; |
|
28 } |
|
29 // CONTENT_* are not prefixed with HTTP_ |
|
30 elseif (in_array($key, array('CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'))) { |
|
31 $headers[$key] = $this->parameters[$key]; |
|
32 } |
|
33 } |
|
34 |
|
35 // PHP_AUTH_USER/PHP_AUTH_PW |
|
36 if (isset($this->parameters['PHP_AUTH_USER'])) { |
|
37 $pass = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : ''; |
|
38 $headers['AUTHORIZATION'] = 'Basic '.base64_encode($this->parameters['PHP_AUTH_USER'].':'.$pass); |
|
39 } |
|
40 |
|
41 return $headers; |
|
42 } |
|
43 } |