curl-and-python

Strange, strange problem

From: Silvio Moioli <silvio_at_moioli.net>
Date: Tue, 31 Jan 2006 09:46:27 +0100

Good moring,
    I'm trying to write a script which (acting like a browser) lets me
send SMS from local sites (Italy). I've already succeeded in doing this
for some (3-4) sites in the past, crafting GET/POST parameters, cookies,
referers, etc but this time I can't get past the "send" page.
I get a quite strange behavior: if I visit the page with a normal
browser (say, Firefox) clicking on the Send button activates some simple
JavaScript code for parameter initialization, and the "index.cfm" page
gets loaded while using pycurl I get a 302 error.
Trying to understand what was going on I used Ethereal: the index.cfm
gets loaded with some POST parameters along with some cookies collected
from the previous pages and the server responds 200 to Firefox (which
makes the SMS to be sent successfully) and 302 to pycurl. The strange
thing about it is that the Location: field redirects to exactly the same
page (index.cfm) and using FOLLOWLOCATION makes libcurl drop the POST
parameters and do a normal GET request, resulting in a not sent SMS ;)

I had a hard time then trying to mimic the browser behavior in every
possible way: now the script gets exactly the same pages, with exactly
the same GET/POST parameters in the same order, the same cookies and
uses the same HTTP headers (I checked every one of them in Ethereal
against Firefox's ones) but I still get that 302.
The only differences I can see at this point are:
    1) the HTTP headers are not in the same order (but that shouldn't
really harm);
    2) images and css files don't get downloaded in my script (I really
hope that's not the problem);
    3) when I do a POST, Firefox sends the header in two different IP
packets, while pycurl uses only one.

Has anyone a hint for me?

I'm using curl/libcurl 7.13.2-2sarge4 (on Debian Sarge, standard 2.6
kernel), Python 2.4 and pycurl 7.13.2-2.

Thanks in advance,

-- 
Silvio Moioli
www.moioli.net
silvio at moioli dot net
"Things should be as simple as possible, but not any simpler" Einstein
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2006-01-31