|
@@ -24,19 +24,14 @@ class HeaderBag extends ParameterBag
|
|
|
protected $type;
|
|
|
|
|
|
/**
|
|
|
- * Replaces the current HTTP headers by a new set.
|
|
|
+ * Constructor.
|
|
|
*
|
|
|
* @param array $parameters An array of HTTP headers
|
|
|
* @param string $type The type (null, request, or response)
|
|
|
*/
|
|
|
- public function replace(array $parameters = array(), $type = null)
|
|
|
+ public function __construct(array $parameters = array(), $type = null)
|
|
|
{
|
|
|
- $this->cacheControl = null;
|
|
|
- $this->parameters = array();
|
|
|
- foreach ($parameters as $key => $value)
|
|
|
- {
|
|
|
- $this->parameters[strtr(strtolower($key), '_', '-')] = $value;
|
|
|
- }
|
|
|
+ $this->replace($parameters);
|
|
|
|
|
|
if (null !== $type && !in_array($type, array('request', 'response')))
|
|
|
{
|
|
@@ -45,6 +40,21 @@ class HeaderBag extends ParameterBag
|
|
|
$this->type = $type;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Replaces the current HTTP headers by a new set.
|
|
|
+ *
|
|
|
+ * @param array $parameters An array of HTTP headers
|
|
|
+ */
|
|
|
+ public function replace(array $parameters = array())
|
|
|
+ {
|
|
|
+ $this->cacheControl = null;
|
|
|
+ $this->parameters = array();
|
|
|
+ foreach ($parameters as $key => $value)
|
|
|
+ {
|
|
|
+ $this->parameters[strtr(strtolower($key), '_', '-')] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns a header value by name.
|
|
|
*
|
|
@@ -76,11 +86,6 @@ class HeaderBag extends ParameterBag
|
|
|
}
|
|
|
|
|
|
$this->parameters[$key] = $value;
|
|
|
-
|
|
|
- if ('cache-control' == $key)
|
|
|
- {
|
|
|
- $this->cacheControl = null;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|