nlv11281 at natlab.research.philips.com
Mon Aug 14 07:03:34 EDT 2006
... >> if req.method == "POST" or req.method == "PUT": ... >> The current version says something similar. >> >> This is wrong. Or at least restictive. > > It may be restrictive but the cgi.FieldStorage class in the main Python > distribution also only supports POST. Unless you can show some sort > of precedent in the way of some other equivalent forms processing library > that supports PUT, I can't see any convincing reason to change it. Some > sort of documentation as to what can be provided in a PUT request as > content would also help. The HTTP RFC 2068 (there's a later version too), as far as I can recall it, explains that only POST requests can be expected to have a body that contains FORM data. All other requests, like GET, PUT, OPTION and so on have entity bodies with different meaning. For a PUT request, the standard expects the body to contain full (or partial since HTTP/1.1) contents of the entity refered to in the URL. A subsequent GET request for the same URL is expected to retrieve the contents as sent by the last PUT request. For that reason, I would strongly object to implementing this patch in the FieldStorage class. It goes against the standards, and because of that, you're on your own here. >> I noticed this because I am PUTting the representation of a resource >> as application/x-www-form-urlencoded and I wasn't allowed to do that >> using FieldStorage. As explained, FieldStorage is correct in not allowing that. Either modify your application to adhere to the standard and use a POST request, or implement your own workaround that will make it work in your specific environment, for example using Graham's solution. Mike.