[HttpFoundation] added missing CONTENT_TYPE and CONTENT_LENGTH to the Request headers (these two headers are not prefixes with HTTP_ -- as per the CGI/1.1 spec, closes #1234)

This commit is contained in:
Fabien Potencier 2011-06-08 11:04:41 +02:00
parent 188e74273a
commit f16e206cd7
2 changed files with 13 additions and 1 deletions

View File

@ -308,7 +308,12 @@ class Request
// FIXME: populate $_FILES
foreach ($this->headers->all() as $key => $value) {
$_SERVER['HTTP_'.strtoupper(str_replace('-', '_', $key))] = implode(', ', $value);
$key = strtoupper(str_replace('-', '_', $key));
if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
$_SERVER[$key] = implode(', ', $value);
} else {
$_SERVER['HTTP_'.$key] = implode(', ', $value);
}
}
// FIXME: should read variables_order and request_order

View File

@ -28,6 +28,13 @@ class ServerBag extends ParameterBag
}
}
// CONTENT_TYPE and CONTENT_LENGTH are not prefixed with HTTP_
foreach (array('CONTENT_TYPE', 'CONTENT_LENGTH') as $key) {
if (isset($this->parameters[$key])) {
$headers[$key] = $this->parameters[$key];
}
}
return $headers;
}
}