Re: [Twisted-Python] twisted.web.client POST data

Hi Vasil:
I'm trying to send a post request like so getPage('http://localhost/test/test/', method='POST' postdata='test=asdf')
I will assume you did things like check your web server's log to see if a connection was made and if there was an error..... Since you are using the POST method, I would expect you would have to set the headers argument (a dictionary). I notice the header argument is missing. I would expect entries such as Content-Type and Content-Length. Cheers, Andrew

Problem was I was missing the content type header. The content length value is calculated somewhere in twisted.web.client I just put in there the same content type firefox sends when posting a form. Now it works. getPage(url,method='POST',postdata=urllib.urlencode({'check_data':check_data}),headers={'Content-Type':'application/x-www-form-urlencoded'}) Thanks for the suggestions. Andrew Francis wrote:

Problem was I was missing the content type header. The content length value is calculated somewhere in twisted.web.client I just put in there the same content type firefox sends when posting a form. Now it works. getPage(url,method='POST',postdata=urllib.urlencode({'check_data':check_data}),headers={'Content-Type':'application/x-www-form-urlencoded'}) Thanks for the suggestions. Andrew Francis wrote:
participants (2)
-
Andrew Francis
-
Vasil Vangelovski