How to use twisted.web2 http clients.
Hello all, I have set up a twisted.web2 http server and would like to use the web2 client to connect to it. I have been using the httplib in Python, but it is tedious to use and has a significant(for my project) bug in it(no 100-continue support). I have asked a similar question a couple of months ago, Cameron Dale responded with an example of how he uses the http client in web2, but the the link he supplied is no longer available and I cannot seem to find a local copy. I looked at his example when he posted the link, but it did not seem like it was relevant to the cases I have. If I am wrong, could you post the example agian Cameron? Thanks. Here is what I need to implement: Streaming POST: 1) create connection 2) set up connection 3) check for a 100-continue and authenticate if necessary. 3) stream data over the connection, in small chunks with unknown content length or from files. 4) check the response. 5) close connection/or reuse it if I can. Multiple One-shot POST, GET, HEAD and DELETES 1) create connection 2) set up connection 3) authenticate if necessary. 3) send multiple POST/GET/HEAD/DELETE commands and retrieve the responses. 4) close connection when done. For the Streaming POSTs I need to support HTTP 1.1, chunked encoding, persistent connections and 100-continue. This means web2, as far as I can tell. The same for the one-shot requests, if I want to use persistent connections, I need web2. Is this correct? Or can I get the same functionality in web? If I have to use web2, could somebody help me in the right direction? If this is possible in web, then a hint in that direction and how i could do it would also be appriciated. Thank you, Brian
On 5/13/08, Brian Carmalt <bca@contact.de> wrote:
I have asked a similar question a couple of months ago, Cameron Dale responded with an example of how he uses the http client in web2, but the the link he supplied is no longer available and I cannot seem to find a local copy. I looked at his example when he posted the link, but it did not seem like it was relevant to the cases I have. If I am wrong, could you post the example agian Cameron? Thanks.
http://git.camrdale.org/?p=apt-p2p.git;a=blob;f=apt_p2p/HTTPDownloader.py It's undergone some changes since then, including adding the fix for ticket #3207. You're probably only interested in the parts of the Peer class that implements the ClientManager interface and submitting requests.
Here is what I need to implement:
Streaming POST: 1) create connection 2) set up connection 3) check for a 100-continue and authenticate if necessary. 3) stream data over the connection, in small chunks with unknown content length or from files. 4) check the response. 5) close connection/or reuse it if I can.
Mine only does no content requests.
Multiple One-shot POST, GET, HEAD and DELETES 1) create connection 2) set up connection 3) authenticate if necessary. 3) send multiple POST/GET/HEAD/DELETE commands and retrieve the responses. 4) close connection when done.
Mine handles multiple GET and HEAD requests, not POST, and DELETE should work but I haven't tried it. Cameron
participants (2)
-
Brian Carmalt
-
Cameron Dale