1 | <?php |
||
18 | class HeaderBag extends Bag |
||
19 | { |
||
20 | /** |
||
21 | * Special HTTP headers that do not have the "HTTP_" prefix, for some reason. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected static $special = array( |
||
26 | 'CONTENT_TYPE', |
||
27 | 'CONTENT_LENGTH', |
||
28 | 'PHP_AUTH_USER', |
||
29 | 'PHP_AUTH_PW', |
||
30 | 'PHP_AUTH_DIGEST', |
||
31 | 'AUTH_TYPE', |
||
32 | ); |
||
33 | |||
34 | /** |
||
35 | * Create a new HeaderBag, derived from the provided environment bag. |
||
36 | * |
||
37 | * @param Bag $environment The environment variables |
||
38 | * @return self |
||
39 | */ |
||
40 | public static function createFromEnvironment(Bag $environment) |
||
56 | |||
57 | /** |
||
58 | * Add a header to the bag |
||
59 | * |
||
60 | * @param mixed $key |
||
61 | * @param mixed $value |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function add($key, $value) |
||
78 | |||
79 | /** |
||
80 | * Get a header from the bag by key |
||
81 | * |
||
82 | * @param mixed $key |
||
83 | * @param array $default The default value if no header matches |
||
84 | * @return array |
||
85 | */ |
||
86 | public function get($key, $default = array()) |
||
90 | |||
91 | /** |
||
92 | * Check if the bag contains a given key |
||
93 | * |
||
94 | * @param mixed $key |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function has($key) |
||
101 | |||
102 | /** |
||
103 | * If the bag contains the given key, return the value, then remove it from the bag. |
||
104 | * |
||
105 | * @param $key |
||
106 | * @return mixed|null |
||
107 | */ |
||
108 | public function remove($key) |
||
112 | |||
113 | /** |
||
114 | * Get the underlying array of the contents of the bag. |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | public function all() |
||
122 | |||
123 | /** |
||
124 | * Normalize header name, converting it to lower-case |
||
125 | * |
||
126 | * @param string $key The case-insensitive header name |
||
127 | * @return string Normalized header name |
||
128 | */ |
||
129 | public function normalizeKey($key) |
||
138 | } |
||
139 |