Am 13.12.2016 14:45 schrieb "Dejan Stošić" <dejanstos...@gmail.com>:



*The problem*
Currently, PHP will parse the incoming HTTP request body only for GET
requests (and store the data in superglobal $_GET) and for POST requests
(and store the data in $_POST).
Additionally it will parse the data only for
*application/x-www-form-urlencoded* or *multipart/form-data *HTTP Content
types.
There are other 3rd party libraries and packages that enhance this and
enable parsing for other request methods and content types, but i feel like
this should have native support at this point.

*Goal*
Ideally, PHP should natively parse the incoming HTTP request body for all
request methods, not only for GET and POST. I guess that completely
replacing the $_POST and $_GET is out of the question as it would lead to
no backward compatibility. Maybe an additional superglobal could be
introduced ($_DATA)?



Have a look at http://pecl.php.net/apfd which triggers the request body
parser on any request method.

Also, http://pecl.php.net/json_post provides a content type handler for
JSON.

Parsing of the request body happens before entering userland, so providing
a pluggable interface (to userland) is not an option currently.

Cheers,
Mike



Thanks

Reply via email to