[Twisted-Python] x-www-urlencoded information loss

Matthias Urlichs smurf at noris.de
Fri May 9 21:32:37 EDT 2003


if somebody uploads a file, the x-url-encoded part with the file data
typically has an extended header along the lines of

Content-Disposition: form-data; name="file"; filename="foo.txt"
Content-Type: application/octet-stream


At the moment, Twisted doesn't seem to store that information (i.e.,
filename and content-type) anywhere. I consider that to be a bug; I don't
want to de-MIMEify the content a second time.

To fix this, the arguments should probably acquire their own "headers"
hash. For instance, in the above example:

request.args["file"][0].headers = \
    {"content-type":       ["application/octet-stream"],
     "Content-Disposition":["form-data; name=\"file\";

That would require to use a subclass of "str" for the arguments (you can't
directly attach a property to a string), but with Python 2.2 this should
be nicely transparent.


More information about the Twisted-Python mailing list