On Jan 14, 6:54 am, ag73 <andygrov...@gmail.com> wrote: > 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
Please show the full traceback. -- http://mail.python.org/mailman/listinfo/python-list