[Web-SIG] a new implementation of multipart/form-data parser

Manlio Perillo manlio_perillo at libero.it
Wed Sep 10 20:02:04 CEST 2008


Hi all.

For my WSGI framework I have implemented a multipart/form-data parser.
http://hg.mperillo.ath.cx/wsgix/diff/70aacc4a8301/wsgix/parse.py

The code has been adapted from cgi.parse_multidata.

I think that the function is more robust of FieldStorage, since you can 
set a max size for field data stored in memory.
The code is more simple, too (since I have done a little review of 
current browsers behaviour, and none of them use multipart/mixed when 
encoding multiple file fields with the same name).

Now I'm going to write a middleware that takes a POST request with data 
encoded in multipart/form-data, and transcode the request entity in 
application/www-form-urlencoded, with file fields saved as:
field_name=<name>&field_path=<path>&field_content_type=<ctype>

where <path> is the temporary path where the file has been stored.

Note that there is a Nginx module 
http://www.grid.net.ru/nginx/upload.en.html
that does this (but don't transcode in application/www-form-urlencoded.


Any one interested?
I really whould like some reviews.



Thanks   Manlio Perillo


More information about the Web-SIG mailing list