@@ -32,28 +32,21 @@ use Firebase\JWT\JWT;
3232
3333# Checks our content type header and parses the content accordingly
3434function get_request_data () {
35+ # TODO: x-www-form-urlencoded still attempts to use json if no parameters were passed in. This was intentionally done to
36+ # TODO: support user scripts that didn't specify a static content type (before it was supported) remove this in a future
37+ # TODO: release. It is preferred that content uses a specified content type.
3538 $ content_types = [
36- "application/x-www-form-urlencoded " => $ _GET ,
37- "application/json " => json_decode (file_get_contents ('php://input ' ), true )
39+ "application/json " => json_decode ( file_get_contents ( ' php://input ' ), true ) ,
40+ "application/x-www-form-urlencoded " => ( empty ( $ _GET )) ? json_decode (file_get_contents ('php://input ' ), true ) : $ _GET
3841 ];
39- # If client passed in a static content type via header, attempt to parse data using that type
40- if (!empty ($ _SERVER ["HTTP_CONTENT_TYPE " ])) {
41- # Check if content type is supported, if so return corresponding parsed request data
42- if (array_key_exists ($ _SERVER ["HTTP_CONTENT_TYPE " ], $ content_types )) {
43- return $ content_types [$ _SERVER ["HTTP_CONTENT_TYPE " ]];
44- }
45- # Return false if the content type is unknown or unsupported
46- else {
47- return false ;
48- }
42+
43+ # Check if content type is supported, if so return corresponding parsed request data
44+ if (array_key_exists ($ _SERVER ["HTTP_CONTENT_TYPE " ], $ content_types )) {
45+ return $ content_types [$ _SERVER ["HTTP_CONTENT_TYPE " ]];
4946 }
50- # If a static content type was not provided, attempt to determine the content type
47+ # Return false if the content type is unknown or unsupported
5148 else {
52- if (!empty ($ _GET )) {
53- return $ _GET ;
54- } else {
55- return json_decode (file_get_contents ('php://input ' ), true );
56- }
49+ return false ;
5750 }
5851}
5952
0 commit comments