Problem with httplib and POST

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


Klaus Alexander Seistrup <spamtrap at magnetic-ink.dk> wrote in
<01b6b30b-d975-4ec1-a6f5-8e341dc13a3b at zigzag.magnetic-ink.dk>: 

>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

Referer: http://www.bludgeon.org:8080/management/editdns.asp?sld_nsrec_id=    
	37792

Connection: Keep-Alive

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

Host: www.bludgeon.org:8080

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

Cookie: SessionTest=enabled;     
	ASPSESSIONIDQQQQGTKQ=GOCGOAOAGANGAMHCEMBACCMB;     
	Domain=Name=BLUDGEON%2EORG

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

Content-length: 66



hostname=TRISTRAM.BLUDGEON.ORG&hostip=4.3.2.1&B1=Update+DNS+Record


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'
Referer: https://www.dotster.com/management/editdns.asp&sld_nsrec_id=37792
\r\n'
Accept-Language: en-us\r\n'
Content-type: application/x-www-form-urlencoded\r\n'
Accept-Encoding: gzip, deflate\r\n'
Host: www.dotster.com\r\n'
Content-Length: 66\r\n'
Cache-Control: no-cache\r\n'
Cookie: SessionTest=enabled;     
	ASPSESSIONIDGQGGGTVY=IEPDIPIDNJAAEFOPCFOMGDIN;     
	Domain=Name=BLUDGEON%2EORG    	\r\n'
\r\n'
hostip=9.9.9.9&B1=Update+DNS+Record&hostname=TRISTRAM.BLUDGEON.ORG'

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