http POST question

Raaijmakers, Vincent (GE Infrastructure) Vincent.Raaijmakers at
Wed Jul 14 14:58:40 CEST 2004

Please tell me if this is true or not..

In a all my applications I used the old fashioned way of "POST" requests:
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
headers = {"Content-type": "application/x-www-form-urlencoded"}
conn = httplib.HTTPConnection("somelocation")
conn.request("POST", "/cgi-bin/query", params, headers)

Now, without thinking.. have to admit.. I always thought that the request object would format 
this request into something like: /cgi-bin/query?spam=1&eggs=2&bacon=0

Until yesterday when I needed a bare bone BaseHTTPServer, creating my own do_POST:

def do_POST(self):
	print self.path

there were no spam, bacon and eggs in "self.path". They are only there when I change conn.request in:
conn.request("POST", "/cgi-bin/query?spam=1&eggs=2&bacon=0", params, headers)

Sniffing on the network learned me that my params are in the header, not in the post request and look like: spam=1&eggs=2&bacon.

So, is it indeed true that I misunderstood the formatting?


More information about the Python-list mailing list