I currently have a bash application that, among other things, uses cURL to upload a file to a web application with the PUT method. I am attempting to duplicate the web application as the client (bash) portion is GPL but the web portion is not. I also cannot alter the client application as it auto-updates itself from the developers’ website.
I have found multitudes of information on how to handle the HTTP POST method with WSGI, CherryPy, Twisted, and practically every way of having Python scripts working on the WWW. However, I can’t find a single thing about the PUT method. Does anyone know how to process a PUT request with WSGI, or is there some other framework with PUT functionality that I am missing?
I currently have a bash application that, among other things, uses cURL to upload
Share
As I understand it, you will just want to read the stream
environ['wsgi.input'], because aPUTrequest will send the entire contents of thePUTas the body of the request.I am not aware of any encoding issues you will have to deal with (other than the fact that it is binary).
Some time ago, I wrote a simple set of PHP scripts to take and give huge files from another server on a LAN. We started with POST, but quickly ran out of memory on the larger files. So we switched to PUT, where the PHP script could take it’s good time looping through
php://input4096 bytes at a time (or whatever)… It works great.Here is the PHP code:
From my experience in handling
multipart/form-datain WSGI withPOST, I have little doubt that you can handle aPUTby just reading the input stream.The python code should be like this: