浏览代码

Merge remote branch 'fabpot/form-put'

* fabpot/form-put:
  [HttpFoundation] fixed typo
  [HttpFoundation] moved the PUT magic dance in createFromGlobals()
  added support for PUT method
Fabien Potencier 14 年之前
父节点
当前提交
02a81de9d6
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      src/Symfony/Component/HttpFoundation/Request.php

+ 10 - 1
src/Symfony/Component/HttpFoundation/Request.php

@@ -127,7 +127,16 @@ class Request
      */
     static public function createFromGlobals()
     {
-        return new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
+        $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
+
+        if ('application/x-www-form-urlencoded' == $request->server->get('CONTENT_TYPE')
+            && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE'))
+        ) {
+            parse_str($this->getContent(), $data);
+            $request->request = new ParameterBag($data);
+        }
+
+        return $request;
     }
 
     /**