Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.

Commit 0080da9

Browse files
author
aglr
committed
If a PUT request is sent with the header "Content-Type: application/json"
the input data will be json_decode as a POST request is decoded. (depends to the '$extended' parameter)
1 parent 5da8e99 commit 0080da9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Runtime.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,23 @@ public static function getUri()
7979
*/
8080
public static function getData($extended = true)
8181
{
82-
switch (static::getMethod()) {
82+
$method = static::getMethod();
83+
84+
switch ($method) {
8385
case Request::METHOD_GET:
8486
return $_GET;
8587

8688
case Request::METHOD_POST:
89+
case Request::METHOD_PUT:
90+
case Request::METHOD_PATCH:
8791
$contentType = static::getHeader('Content-Type');
8892

8993
switch ($contentType) {
9094
case 'application/x-www-form-urlencoded':
91-
return $_POST;
95+
return ${'_'.strtoupper($method)};
9296

9397
case 'application/json':
9498
$input = file_get_contents('php://input');
95-
9699
if (true !== $extended ||
97100
true !== function_exists('json_decode')) {
98101
return $input;
@@ -110,12 +113,6 @@ public static function getData($extended = true)
110113
return file_get_contents('php://input');
111114
}
112115

113-
break;
114-
115-
case Request::METHOD_PUT:
116-
case Request::METHOD_PATCH:
117-
return file_get_contents('php://input');
118-
119116
default:
120117
return null;
121118
}

0 commit comments

Comments
 (0)