Skip to content

Commit 75df4a6

Browse files
wusuopufabpot
authored andcommitted
[HttpFoundation] Fix an issue caused by php's Bug #66606.
1 parent 6116d33 commit 75df4a6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,20 @@ public function initialize(array $query = array(), array $request = array(), arr
260260
*/
261261
public static function createFromGlobals()
262262
{
263-
$request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
263+
// With the php's bug #66606, the php's built-in web server
264+
// stores the Content-Type and Content-Length header values in
265+
// HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields.
266+
$server = $_SERVER;
267+
if ('cli-server' === php_sapi_name()) {
268+
if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) {
269+
$server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH'];
270+
}
271+
if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
272+
$server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE'];
273+
}
274+
}
275+
276+
$request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $server);
264277

265278
if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
266279
&& in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))

0 commit comments

Comments
 (0)