From c80ab423480d06c594531a65803d2d394e0231d3 Mon Sep 17 00:00:00 2001 From: Chekote Date: Fri, 6 May 2011 08:00:02 -0500 Subject: [PATCH] Modified Request to handle data submitted via PUT --- src/Symfony/Component/HttpFoundation/Request.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 65ecddc65391f..ea24eab9053e7 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -121,13 +121,23 @@ public function initialize(array $query = array(), array $request = array(), arr } /** - * Creates a new request with values from PHP's super globals. + * Creates a new request with values from PHP's super globals. Note that if the request method + * is PUT, then the php://input stream will also be processed for request values. * * @return Request A new request */ static public function createFromGlobals() { - return new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER); + $content = null; + $request = array(); + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'PUT') { + $content = file_get_contents('php://input'); + parse_str($content, $request); + } + + $request = array_merge($request, $_POST); + + return new static($_GET, $request, array(), $_COOKIE, $_FILES, $_SERVER, $content); } /**