Problem with httplib and POST

Ray Van Dolson leovd at
Thu Nov 8 18:19:25 CET 2001

Klaus Alexander Seistrup <spamtrap at> wrote in
<01b6b30b-d975-4ec1-a6f5-8e341dc13a3b at>: 

>Have you tried
>h.putrequest("POST", "/management/editdns.asp")
>     [···]
>params = urllib.urlencode({'hostname': HOST_HERE, 'hostip': NEW_IP,
>     'B1': 'Update DNS Record', 'Update': '1', 'sld_nsrec_id':
>     '4444'}) 

Yeah, I tried that.  502 Server Error was the result.  I managed to set up  
stunnel on my server and could then sniff the connection as I ran it 
through my web browser.  I decided to do it with an HTTP/1.0 browser (in 
this case, Netscape 3.04).  Here's what I sniffed:

POST /management/editdns.asp?Update=1&sld_nsrec_id=37792 HTTP/1.0


Connection: Keep-Alive

User-Agent: Mozilla/3.04 (WinNT; U)


Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

Cookie: SessionTest=enabled;     

Content-type: application/x-www-form-urlencoded

Content-length: 66


After enabling h.set_debuglevel(1) in my code, here's what it appears I'm 
sending out:

POST /management/editdns.asp?Update=1&sld_nsrec_id=37792 HTTP/1.0\r\n'
Accept: text/html\r\n'
Accept-Language: en-us\r\n'
Content-type: application/x-www-form-urlencoded\r\n'
Accept-Encoding: gzip, deflate\r\n'
Content-Length: 66\r\n'
Cache-Control: no-cache\r\n'
Cookie: SessionTest=enabled;     
	Domain=Name=BLUDGEON%2EORG    	\r\n'

Things that are different--Netscape uses a Keep-Alive connection.  I 
didn't think this was supported by HTTP/1.0.  In any case, when I use it 
in my script, (and use a correspondding h.close() statement--it still 
won't work.  Also, the parameters in my POST urlencode string are in a 
different order.  I doubt this would make the difference, and in any case, 
I can't seem to preserve the order of things in dictionaries.

Other than that, and the order of the headers (shouldn't matter?), 
everything seems to be exactly the same!  Any other ideas?  I guess I may 
email dotster and see if anyone is willing to help me out.

Thanks much,
Ray Van Dolson

More information about the Python-list mailing list