[TASK] Decode body for alternative request methods 61/47161/4
authorAndreas Wolf <andreas.wolf@typo3.org>
Wed, 9 Mar 2016 09:15:34 +0000 (10:15 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 27 Oct 2016 12:24:14 +0000 (14:24 +0200)
PHP only decodes data for POST requests. This commit adds a similar
support (using the same mechanisms, according to the PHP docs) for other
request methods. Currently, it is limited to PUT, PATCH and DELETE, the
request methods that may have a body according to the HTTP spec.

Change-Id: Icdf14f48bf84258958dbca704dfa94474f6894bb
Resolves: #74532
Releases: master
Reviewed-on: https://review.typo3.org/47161
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Http/ServerRequestFactory.php

index 53f1cbf..15d1ffc 100644 (file)
@@ -58,6 +58,9 @@ class ServerRequestFactory
             $request = $request->withQueryParams($queryParameters);
         }
         $parsedBody = GeneralUtility::_POST();
+        if (empty($parsedBody) && in_array($method, ['PUT', 'PATCH', 'DELETE'])) {
+            parse_str(file_get_contents('php://input'), $parsedBody);
+        }
         if (!empty($parsedBody)) {
             $request = $request->withParsedBody($parsedBody);
         }