tobias <fatb...@web.de> added the comment: Actually, I think this whole issue is more complex. For example, consider a (fictious) CGI script where users can upload an image and a description and the script sends a success/error message in return.
In this case, one has to: - read the HTTP request header from stdin as US-ASCII - read the image from stdin as raw binary data - read the description from stdin as a string in some encoding - write the HTTP response header to stdout as US-ASCII - write the response message to stdout in some (other) encoding - write error messages to server log via stderr as US-ASCII Also, there are cases when a cgi script should return binary data instead (e.g., images or archive files) or apply a transfer encoding (e.g., gzip). Although FieldStorage only cares about reading, it still has to cope with intermixed textual and binary data. So the only practical way in my opinion is to use raw binary data and have FieldStorage decode strings on demand, since only the programmer knows whether a field should contain text or binary data. FieldStorage should offer two methods for this purpose: one for reading binary data and another for reading and decoding strings on-the-fly (possibly using a default encoding passed to its constructor). ---------- nosy: +tobias _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4953> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com