summaryrefslogtreecommitdiff
path: root/django/http/__init__.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-08-17 15:05:54 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-08-17 15:05:54 +0000
commitfcec755f01cfaba2a85bfc9511876debbce98631 (patch)
treee990effbcd90e4d405b0f9dcc70cb38e47b6f3dc /django/http/__init__.py
parent0f92ac52cbf81fb2ac01755c558e2e6ad54700e8 (diff)
newforms-admin: Merged from trunk up to [5916]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5918 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/http/__init__.py')
-rw-r--r--django/http/__init__.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py
index bcb06cbb87..7cd47481dc 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -2,7 +2,7 @@ import os
from Cookie import SimpleCookie
from pprint import pformat
from urllib import urlencode
-from django.utils.datastructures import MultiValueDict
+from django.utils.datastructures import MultiValueDict, FileDict
from django.utils.encoding import smart_str, iri_to_uri, force_unicode
RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
@@ -84,13 +84,15 @@ def parse_file_upload(header_dict, post_data):
if not name_dict['filename'].strip():
continue
# IE submits the full path, so trim everything but the basename.
- # (We can't use os.path.basename because it expects Linux paths.)
+ # (We can't use os.path.basename because that uses the server's
+ # directory separator, which may not be the same as the
+ # client's one.)
filename = name_dict['filename'][name_dict['filename'].rfind("\\")+1:]
- FILES.appendlist(name_dict['name'], {
+ FILES.appendlist(name_dict['name'], FileDict({
'filename': filename,
'content-type': 'Content-Type' in submessage and submessage['Content-Type'] or None,
'content': submessage.get_payload(),
- })
+ }))
else:
POST.appendlist(name_dict['name'], submessage.get_payload())
return POST, FILES
@@ -212,18 +214,22 @@ class HttpResponse(object):
status_code = 200
- def __init__(self, content='', mimetype=None, status=None):
+ def __init__(self, content='', mimetype=None, status=None,
+ content_type=None):
from django.conf import settings
self._charset = settings.DEFAULT_CHARSET
- if not mimetype:
- mimetype = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, settings.DEFAULT_CHARSET)
+ if mimetype:
+ content_type = mimetype # For backwards compatibility
+ if not content_type:
+ content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
+ settings.DEFAULT_CHARSET)
if not isinstance(content, basestring) and hasattr(content, '__iter__'):
self._container = content
self._is_string = False
else:
self._container = [content]
self._is_string = True
- self.headers = {'Content-Type': mimetype}
+ self.headers = {'Content-Type': content_type}
self.cookies = SimpleCookie()
if status:
self.status_code = status