Skip to content

Commit f16e206

Browse files
committed
[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)
1 parent 188e742 commit f16e206

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,12 @@ public function overrideGlobals()
308308
// FIXME: populate $_FILES
309309

310310
foreach ($this->headers->all() as $key => $value) {
311-
$_SERVER['HTTP_'.strtoupper(str_replace('-', '_', $key))] = implode(', ', $value);
311+
$key = strtoupper(str_replace('-', '_', $key));
312+
if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
313+
$_SERVER[$key] = implode(', ', $value);
314+
} else {
315+
$_SERVER['HTTP_'.$key] = implode(', ', $value);
316+
}
312317
}
313318

314319
// FIXME: should read variables_order and request_order

src/Symfony/Component/HttpFoundation/ServerBag.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public function getHeaders()
2828
}
2929
}
3030

31+
// CONTENT_TYPE and CONTENT_LENGTH are not prefixed with HTTP_
32+
foreach (array('CONTENT_TYPE', 'CONTENT_LENGTH') as $key) {
33+
if (isset($this->parameters[$key])) {
34+
$headers[$key] = $this->parameters[$key];
35+
}
36+
}
37+
3138
return $headers;
3239
}
3340
}

0 commit comments

Comments
 (0)