On Thu, Dec 1, 2011 at 10:14 AM, Thibault Jouannic <[email protected]> wrote:
> Hi django devs, > > I'm looking for some news about the ticket #12635. > > https://code.djangoproject.com/ticket/12635 > > Today, it's still impossible to easily access post data when sending a > PUT request. Since I'm trying to build a restful web service using > django, this is quite a problem. > > It's been told in another thread to use the `request.raw_post_data` > attribute, however I cannot think of a valid reason for why put data > could'nt be has easily accessible as post data. > > I see in the ticket that the 1.4 milestone was deleted. Was the ticket > abandoned? > > I've seen a lot of discussions and tickets about rest, and I know it's > a complex issue, but since I'm kinda new here, it's hard to know what > is the current state of the problem. > > "GET data" and "POST data" are just the terms that are used for data that appears in the URL query string, and the HTTP request body, respectively. They don't actually have anything to do with the request method used* If you receive a POST (or a PUT, or DELETE) at http://www.example.com/web_service?param=value, for example, then request.GET will be populated with {'param': 'value'}, no matter what the method is. Similarly, if you attach a body to a PUT request, then it will be available just as in a POST. request.POST is designed to work with HTML form submissions; data in either x/www-form-urlencoded or multipart/form-data, and it contains any key/value pairs parsed out of that sort of data. That's usually not what you attach to a PUT request, though (and occasionally, it's not what you attach to a POST, either). In that case, request.raw_post_data is the way to get at the unprocessed request body. What you are after is just the body of the HTTP request, and it happens to be called 'raw_post_data' in django. It's a bit of an unfortunate name, since there is no difference between the payload of a POST request and that of a PUT request, but that's what it is. Ian * RFC-2616 prohibits a body on certain kinds of requests, so in practice, you won't see "POST data" on a GET or DELETE request, but you could see "GET data" on pretty much anything. -- Regards, Ian Clelland <[email protected]> -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
