Pierre, I am repeating some questions I already stated in another thread, 'CGI POST problem', but do you have any opinions on how CGIHTTPServer's do_POST handles requests? It looks to me like it always expects form data to be part of the POST command header, in the path of the URL, just like a GET request. Am I understanding the code incorrectly?

The code in CGIHTTPServer is not very easy to understand, but it does
read the request body, as many bytes as indicated in the Content-Length
header. See line 262 (in the Python 2.4 distribution) or 250 in Python 2.3 (this is the Windows version) :


                data = self.rfile.read(nbytes)

Then this data is sent to the standard input of the CGI script. If this script is a Python program using the cgi module, it usually creates a cgi.FieldStorage() instance : upon creation, the standard input is read (in self.read_urlencoded() for instance) and the string collected is processed to produce a dictionary-like object, with keys matching the form field names

This is compliant with the CGI specification (HTTP doesn't say anything about the management of data sent by POST requests). The code I sent is an alternative to CGI, leaving the management of this data (available in self.body) to a method of the RequestHandler instance

Regards,
Pierre
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to