Thanks a lot for the quick reply!<div><br></div><div>I was kind of struggling in my mind about whether to post to twisted-python or twisted-web list and I guess I chose the wrong one because I assumed that the problem was in they way I was using trial. Anyways, thanks again and Twisted is awesome. ;-)</div>
<div><br></div><div>- Teemu<br><br><div class="gmail_quote">On Wed, Apr 9, 2008 at 12:12 AM, Grant Baillie <<a href="mailto:grant@osafoundation.org">grant@osafoundation.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On 8 Apr, 2008, at 04:28, Teemu Harju wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8x;border-left:1px #ccc solid;padding-left:1ex">
...<br>
<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8x;border-left:1px #ccc solid;padding-left:1ex"><div class="Ih2E3d">
My problem is that I'm experimenting with "trial" to be able to test my code. (I've heard that it is a wise thing to do ;-)). What I have is a simple HTTP resource that allows POSTing data. I made this example to illustrate my problem...<br>
<br></div>
...<br>
</blockquote><div class="Ih2E3d">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8x;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8x;border-left:1px #ccc solid;padding-left:1ex">
def test_postdata(self):<br>
d = client.getPage(self.getURL("test"), method="POST",<br>
postdata=urllib.urlencode({"test": "data"}))<br>
d.addCallback(self.failIfEqual, "{}")<br>
return d<br>
<br>
</blockquote>
<br></div>
You need to specify a Content-Type in your POST request, e.g.:<div class="Ih2E3d"><br>
<br>
d = client.getPage(self.getURL("test"), method="POST",<br></div>
postdata=urllib.urlencode({"test": "data"}),<br>
headers={"Content-Type": "application/x-www-form-urlencoded"})<br>
<br>
Otherwise, your POST request is sent as text/html, and the HTTP server code won't know to parse args out of the request body.<br>
<br>
(Probably this should have gone to twisted-web rather than twisted-python, since in the end it wasn't really about trial, but http ;).<br>
<br>
--Grant<br>
<br>
<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Teemu Harju<br><br>email/jabber: <a href="mailto:teemu.harju@gmail.com">teemu.harju@gmail.com</a><br>blog: <a href="http://www.teemuharju.net">http://www.teemuharju.net</a><br>
<br>~~ "A computer is like air conditioning: it becomes useless when you open windows." ~~
</div>