File tree Expand file tree Collapse file tree
pfSense-pkg-API/files/etc/inc/api/framework Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,14 +30,24 @@ require_once("auth.inc");
3030require_once ("functions.inc " );
3131use Firebase \JWT \JWT ;
3232
33- # Gathers our URL form encoded data or JSON body data from our request and places them in a single array
33+ # Checks our content type header and parses the content accordingly
3434function get_request_data () {
35- $ data = $ _GET ; // Accept HTTP requests in URL encoded format
36- // Check if our URL encoded parameters are empty, if so try JSON encoded parameters
37- if (empty ($ data )) {
38- $ data = json_decode (file_get_contents ('php://input ' ), true );
35+ # Support application/x-www-form-urlencoded content type
36+ if (strtolower ($ _SERVER ["HTTP_CONTENT_TYPE " ] === "application/x-www-form-urlencoded " )) {
37+ return $ _GET ;
38+ }
39+ # Support application/json content type
40+ elseif (strtolower ($ _SERVER ["HTTP_CONTENT_TYPE " ] === "application/json " )) {
41+ return json_decode (file_get_contents ('php://input ' ), true );
42+ }
43+ # If a static content type was not provided, attempt to determine the content type
44+ else {
45+ if (!empty ($ _GET )) {
46+ return $ _GET ;
47+ } else {
48+ return json_decode (file_get_contents ('php://input ' ), true );
49+ }
3950 }
40- return $ data ;
4151}
4252
4353# Check our local pfSense version
You can’t perform that action at this time.
0 commit comments