From ac2a7c116dcc0591c5cb55f75b687ef9e8be632e Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 18 Jul 2005 05:52:06 +0000 Subject: [PATCH] Changed django.utils.httpwrappers.parse_file_upload() NOT to be coupled to mod_python git-svn-id: http://code.djangoproject.com/svn/django/trunk@165 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/httpwrappers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/django/utils/httpwrappers.py b/django/utils/httpwrappers.py index 513a5bc0d7..764b29ec1c 100644 --- a/django/utils/httpwrappers.py +++ b/django/utils/httpwrappers.py @@ -40,7 +40,7 @@ class ModPythonRequest(HttpRequest): def _load_post_and_files(self): "Populates self._post and self._files" if self._req.headers_in.has_key('content-type') and self._req.headers_in['content-type'].startswith('multipart'): - self._post, self._files = parse_file_upload(self._req) + self._post, self._files = parse_file_upload(self._req.headers_in, self._req.read()) else: self._post, self._files = QueryDict(self._req.read()), datastructures.MultiValueDict() @@ -112,12 +112,12 @@ class ModPythonRequest(HttpRequest): META = property(_get_meta) REQUEST = property(_get_request) -def parse_file_upload(req): - "Returns a tuple of (POST MultiValueDict, FILES MultiValueDict), given a mod_python req object" +def parse_file_upload(header_dict, post_data): + "Returns a tuple of (POST MultiValueDict, FILES MultiValueDict)" import email, email.Message from cgi import parse_header - raw_message = '\r\n'.join(['%s:%s' % pair for pair in req.headers_in.items()]) - raw_message += '\r\n\r\n' + req.read() + raw_message = '\r\n'.join(['%s:%s' % pair for pair in header_dict.items()]) + raw_message += '\r\n\r\n' + post_data msg = email.message_from_string(raw_message) POST = datastructures.MultiValueDict() FILES = datastructures.MultiValueDict()