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

Vasil Vangelovski vvangelovski at gmail.com
Tue Sep 16 03:41:40 EDT 2008


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:
> Hi Vasil:
> 
>> I'm trying to send a post request like so
>> getPage('http://localhost/test/test/', method='POST' postdata='test=asdf')
> 
>> But the server script doesnt get any post arguments.
>> I was looking at the code for web.client and cant see where im doing
>> wrong here.
>> Any ideas what might be the problem? I'm using an svn checkout of Twisted.
> 
> 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
> 
> 
> 
> 
>       
> 
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python





More information about the Twisted-Python mailing list