Skip to content

Commit 66c8908

Browse files
committed
Parse PUT and PATCH when content-type is application/x-www-form-urlencoded
1 parent 4a8ed27 commit 66c8908

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/server.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@
44
$_PATCH = array();
55

66
$request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
7+
$content_type = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '';
78
$data_values = $_GET;
89
if ($request_method === 'POST') {
910
$data_values = $_POST;
1011
}
1112
else if ($request_method === 'PUT') {
12-
parse_str($http_raw_post_data, $_PUT);
13-
$data_values = $_PUT;
13+
if (strpos($content_type, 'application/x-www-form-urlencoded') === 0) {
14+
parse_str($http_raw_post_data, $_PUT);
15+
$data_values = $_PUT;
16+
}
1417
}
1518
else if ($request_method === 'PATCH') {
16-
parse_str($http_raw_post_data, $_PATCH);
17-
$data_values = $_PATCH;
19+
if (strpos($content_type, 'application/x-www-form-urlencoded') === 0) {
20+
parse_str($http_raw_post_data, $_PATCH);
21+
$data_values = $_PATCH;
22+
}
1823
}
1924

2025
$test = isset($_SERVER['HTTP_X_DEBUG_TEST']) ? $_SERVER['HTTP_X_DEBUG_TEST'] : '';

0 commit comments

Comments
 (0)