[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

Glenn Linderman report at bugs.python.org
Mon Jan 10 20:56:33 CET 2011


Glenn Linderman <v+python at g.nevcal.com> added the comment:

Victor said:
Don't you think that a warning would be appropriate if sys.stdin is passed 
here?
---
        # self.fp.read() must return bytes
        if isinstance(fp,TextIOBase):
            self.fp = fp.buffer
        else:
            self.fp = fp
---
Maybe a DeprecationWarning if we would like to drop support of TextIOWrapper 
later :-)

I say:
I doubt we ever want to Deprecate the use of "plain stdin" as the default (or as an explicit) parameter for FieldStorage's fp parameter.  Most usage of FieldStorage will want to use stdin; if FieldStorage detects that stdin is TextIOBase (generally it is) and uses its buffer to get binary data, that is very convenient for the typical CGI application.  I think I agree with the rest of your comments.

Etienne said:
is sendfile() available on Windows ? i thought the Apache server could
use that to upload files without having to buffer files in memory..

I say:
I don't think it is called that, but similar functionality may be available on Windows under another name.  I don't know if Apache uses it or not.  But I have no idea how FieldStorage could interact with Apache via the CGI interface, to access such features.  I'm unaware of any APIs Apache provides for that purpose, but if there are some, let me know.  On the other hand, there are other HTTP servers besides Apache to think about. 

I'm also not sure if sendfile() or equivalent, is possible to use from within FieldStorage, because it seems in practice we don't know the size of the uploaded file without parsing it (which requires buffering it in memory to look at it).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4953>
_______________________________________


More information about the Python-bugs-list mailing list