File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -141,20 +141,31 @@ private function _detectUri()
141141
142142 $ data = array ();
143143
144- if ($ this ->_request ->getMethod () === RequestMethod::PUT ) {
144+ $ contentType = trim (explode ("; " , $ this ->_request ->getHeader ()->getContentType ())[0 ]);
145+
146+ if (count ($ _POST ) > 0 ) {
147+ $ data = $ _POST ;
148+ } elseif ($ this ->_request ->getMethod () === RequestMethod::PUT ) {
145149 $ handle = fopen ("php://input " , "r " );
146150 $ rawData = '' ;
147151 while ($ chunk = fread ($ handle , 1024 )) {
148152 $ rawData .= $ chunk ;
149153 }
150154
151- parse_str ($ rawData , $ data );
152- } elseif (count ($ _POST ) > 0 ) {
153- $ data = $ _POST ;
155+ switch ($ contentType ) {
156+ case "application/json " :
157+ $ data = json_decode ($ rawData , true );
158+ break ;
159+ case "application/xml " :
160+ $ data = (array )simplexml_load_string ($ rawData );
161+ break ;
162+ default :
163+ parse_str ($ rawData , $ data );
164+ break ;
165+ }
154166 } elseif ($ this ->_request ->getMethod () !== RequestMethod::GET ) {
155167 $ rawData = file_get_contents ("php://input " );
156168
157- $ contentType = trim (explode ("; " , $ this ->_request ->getHeader ()->getContentType ())[0 ]);
158169 switch ($ contentType ) {
159170 case "application/json " :
160171 $ data = json_decode ($ rawData , true );
You can’t perform that action at this time.
0 commit comments