[Tutor] HTTPLib and POST problem with '?'

A printers@sendme.cz
Sat, 12 Jan 2002 14:06:35 +0100


Hi,

If I use example from Python doc
like this
####################
import httplib, urllib
 params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
 h = httplib.HTTP("www.musi-cal.com:80")
 h.putrequest("POST", "/cgi-bin/script.cgi")
 h.putheader("Content-type", "application/x-www-form-urlencoded")
 h.putheader("Content-length", "%d" % len(params))
 h.putheader('Accept', 'text/plain')
 h.putheader('Host', 'www.musi-cal.com')
 h.endheaders()
 h.send(params)
 reply, msg, hdrs = h.getreply()
print reply # should be 200
data = h.getfile().read() # get the raw HTML
################
it works well but only if the script is like
http://www.musi-cal.com/cgi-bin/script.cgi
but if the script is like
http://www.musi-cal.com/cgi-bin/script.cgi?name=Paul
(note a part after ? ) it means that PUTREQUEST should be

 h.putrequest("POST", "/cgi-bin/script.cgi?name=Paul")

but httplib ignores everything after '?' and sends only
/cgi-bin/script.cgi
  again
Does anyone have any idea how it can be change to be ?
 sent the complete path(script)?
Thanks.
Ladislav