Skip to content

Commit

Permalink
[HttpFoundation] added missing CONTENT_TYPE and CONTENT_LENGTH to the…
Browse files Browse the repository at this point in the history
… Request headers (these two headers are not prefixes with HTTP_ -- as per the CGI/1.1 spec, closes #1234)
  • Loading branch information
fabpot committed Jun 8, 2011
1 parent 188e742 commit f16e206
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -308,7 +308,12 @@ public function overrideGlobals()
// 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
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/HttpFoundation/ServerBag.php
Expand Up @@ -28,6 +28,13 @@ public function getHeaders()
}
}

// 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;
}
}

0 comments on commit f16e206

Please sign in to comment.