"Pierre Quentel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Here is an example of how to get the POST data : > > # def do_POST(self): > # ctype, pdict = > cgi.parse_header(self.headers.getheader('content-type')) > # length = int(self.headers.getheader('content-length')) > # if ctype == 'multipart/form-data': > # self.body = cgi.parse_multipart(self.rfile, pdict) > # elif ctype == 'application/x-www-form-urlencoded': > # qs = self.rfile.read(length) > # self.body = cgi.parse_qs(qs, keep_blank_values=1) > # else: > # self.body = {} # Unknown content-type > # # throw away additional data [see bug #427345] > # while select.select([self.rfile._sock], [], [], 0)[0]: > # if not self.rfile._sock.recv(1): > # break > # self.handle_data() > > where handle_data() is the method where you will process the data received > > The part related to bug #427345 is copied from CGIHTTPServer > > For an example of use you can take a look at the CustomHTTPServer in > Karrigell (http://karrigell.sourceforge.net)
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? It would also make sense to me that CGIHTTPServer should use the cgi module like you do in your example, but it doesn't use cgi. Any opinions on that? Is there a history there? I don't know enough about HTTP, especially about its history, but was this a change in the HTTP specification at some point? Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list