Hi, I am trying to parse data posted to a Python class that extends http.server.BaseHTTPRequestHandler. Here is the code I am using:
def do_POST(self): ctype, pdict = cgi.parse_header(self.headers['Content-Type']) length = int(self.headers['Content-Length']) if ctype == 'application/x-www-form-urlencoded': qs = self.rfile.read(length) print("qs="+str(qs)) form = urllib.parse.parse_qs(qs, keep_blank_values=1) The print statement shows the following output, so it looks like the data is being posted correctly: qs=b'file_data=b %27IyEvdXNyL2Jpbi9lbnYgcHl0aG9uCiMgZW5jb2Rpbmc6IHV0Zi04CiIiIgp1bnRpdGxlZC5weQoK %5CnQ3JlYXRlZCBieSBBbmR5IEdyb3ZlIG9uIDIwMDgtMTItMDIuCkNvcHlyaWdodCAoYykgMjAwOCBf %5CnX015Q29tcGFueU5hbWVfXy4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KIiIiCgppbXBvcnQgc3lzCmlt %5CncG9ydCBvcwoKCmRlZiBtYWluKCk6CglwcmludCAibmFtZTE9dmFsdWUxIgoJcHJpbnQgIm5hbWUy %5CnPXZhbHVlMiIKCgppZiBfX25hbWVfXyA9PSAnX19tYWluX18nOgoJbWFpbigpCgo%3D %5Cn%27&filename=test.py' However, the last line of code that calls parse_qs causes the following exception to be thrown: <class 'TypeError'> Type str doesn't support the buffer API I haven't been able to find any information on the web about this. Any pointers would be appreciated. I am using ActivePython 3.0 and have tried this on Linux and Max OS X with the same outcome. Thanks, Andy. -- http://mail.python.org/mailman/listinfo/python-list