Re: [RFC Proposal] Introducing New Global Variable to Support Other HTTP Methods and Content Types
| From: | Rowan Collins | Date: | Tue, 13 Dec 2016 15:49:14 +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-97387@lists.php.net to get a copy of this message | ||
On 13 December 2016 13:38:53 GMT+00:00, "Dejan Stošić" <dejanstosic7@gmail.com>
wrote:
>*Disclaimer*
>Sorry if this has been discussed before, i tried searching, but i
>couldn't
>find much information.
It has, quite often actually. Here's a few threads I found in a quick search that look
relevant:
https://marc.info/?t=138003492500001&r=1&w=2
https://marc.info/?t=141329101900006&r=1&w=2
https://marc.info/?t=144226586800002&r=1&w=2
https://marc.info/?t=140822909300001&r=1&w=2
https://marc.info/?t=138069733000002&r=1&w=2
https://marc.info/?t=134822559800006&r=1&w=2
>*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).
This isn't actually true. Despite the names, $_GET and $_POST don't actually have anything
to do with the HTTP request verb. One tokenises the URL's "query string", and the
other the request body. For a GET request, there is no body to parse, but for a POST request,
it's perfectly normal for both to be populated.
>Additionally it will parse the data only for
>*application/x-www-form-urlencoded* or *multipart/form-data *HTTP
>Content
>types.
This much is true, but as you'll see from previous discussions, it's not entirely clear
how to usefully extend it. If we hard code the rules (e.g. the options json_decode offers) we limit
people's options. If we give a pluggable interface, people might as well just parse the raw
input themselves.
Basically, you're not the first to think "some kind of support" is needed, but as yet
nobody has come up with a compelling description of just what that support should look like.
However, don't let that discourage you. If you do a bit more digging into the archives to
understand the challenges, maybe you can come up with a new take on the idea.
Regards,
--
Rowan Collins
[IMSoP]