Issue678557

classification
Title: cgi parsing of multipart/form-data broken
Type: Severity: normal
Components: Library Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cwdjmd, gbgbgb50, pjenvey
Priority: low Keywords:

Created on 2003-02-01.05:14:04 by anonymous, last changed 2008-06-08.22:29:11 by pjenvey.

Messages
msg814 (view) Author: Nobody/Anonymous (nobody) Date: 2003-02-01.05:14:04
While Jython works well in a CGI script normally, it
breaks when handed a POST method using
multipart/form-data to submit the values of the fields
of the form.  Examining the value of the
cgi.FieldStorage instance after it's created, we find
that all the fields are there, but they all have "None"
as their value.

This is using Jython 2.1, Python 2.1, and Java 1.2 on a
Solaris 2.6 platform, and the Apache web server.

Bill Janssen   <bill@janssen.org>
msg815 (view) Author: Chris Dixon (cwdjmd) Date: 2003-03-27.12:48:13
Logged In: YES 
user_id=743507

parsing of a file upload using a POST with
multipart/form-data works. All other fields get dropped.

This is using Jython 2.1, Python 2.1 and Java 1.3 on Redhat
7.1 with Apache
msg816 (view) Author: Chris Dixon (cwdjmd) Date: 2003-03-27.12:48:38
Logged In: YES 
user_id=743507

parsing of a file upload using a POST with
multipart/form-data works. All other fields get dropped.

This is using Jython 2.1, Python 2.1 and Java 1.3 on Redhat
7.1 with Apache
msg817 (view) Author: gunter bach (gbgbgb50) Date: 2003-10-05.14:11:37
Logged In: YES 
user_id=866995

The problem here is the different filehandling systems from
C and Java:
The method "make_file" of the class FieldStorage (used for
multipart cgi-data) creates a temp-file with the desired
functionality on cpython. On Jython this seems not to work
correctly.

My proposal is to use cStringIO instead:

def make_file(self, binary=None):
    import cStringIO
    return cStringIO.StringIO()

Here the complete Multipartdata is stored in memory instead
of /tmp/. In my opinion this is more elegant since
main-memory is not a big issue.


msg3255 (view) Author: Philip Jenvey (pjenvey) Date: 2008-06-08.22:29:10
make_file uses tempfile.TemporaryFile("w+b"), which works on trunk. I 
believe it even works on the 2.2 release also. closing out
History
Date User Action Args
2008-06-08 22:29:11pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg3255
nosy: + pjenvey
2003-02-01 05:14:04anonymouscreate