Re: [RFC Proposal] Introducing New Global Variable to Support Other HTTP Methods and Content Types
| From: | Michael Wallner | Date: | Tue, 13 Dec 2016 19:25:55 +0000 |
| Subject: | Re: [RFC Proposal] Introducing New Global Variable to Support Other HTTP Methods and Content Types | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97391@lists.php.net to get a copy of this message | ||
Am 13.12.2016 14:45 schrieb "Dejan Stošić" <dejanstosic7@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