Opened 13 years ago
Closed 13 years ago
#18215 closed New feature (duplicate)
Don't assume POST data is always application/x-www-form-urlencoded
Reported by: | Steve Lacy | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It seems as though the code in HttpRequest that takes the raw POST data and turns it into request.POST (a QueryDict instance) always assumes that the incoming data is form encoded. In fact, the QueryDict class itself does the decoding, which seems a bit odd to me.
Many web application frameworks are using JSON (application/javascript or text/json, usually) encoded POST bodies, and other frameworks will use (gasp!) XML. Django should look at the request.metaCONTENT_TYPE of the incoming data, and use the right deterializers. Supported deserializers should be "form encoded" (the current), json (via simplejson) and likely XML .
REST frameworks like django-rest-framework and tastypie have better handling of POST/PUT data than Django itself, irrespective of the "RESTyness" of the whole thing.
Duplicate of #5611.