Don't assume 'boundary' is last field in Content-Type header.

http://groups.google.com/group/python-tornado/browse_thread/thread/d0531e331c189c56#

Closes #172.
This commit is contained in:
Ben Darnell 2010-11-19 14:04:53 -08:00
parent cb232b22da
commit 9e965556ff
1 changed files with 6 additions and 3 deletions

View File

@ -357,9 +357,12 @@ class HTTPConnection(object):
self._request.arguments.setdefault(name, []).extend(
values)
elif content_type.startswith("multipart/form-data"):
if 'boundary=' in content_type:
boundary = content_type.split('boundary=',1)[1]
if boundary: self._parse_mime_body(boundary, data)
fields = content_type.split(";")
for field in fields:
k, sep, v = field.partition("=")
if k == "boundary" and v:
self._parse_mime_body(v, data)
break
else:
logging.warning("Invalid multipart/form-data")
self.request_callback(self._request)