summaryrefslogtreecommitdiff
path: root/django/test/client.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2010-08-09 21:22:37 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2010-08-09 21:22:37 +0000
commit6001ba016a3db4701d56abc6d30868d4e5d88dbf (patch)
tree7a42c57d802484300c2384d3cd3a968de1804383 /django/test/client.py
parentc7bd48cb9f645e5ff07d1e68b86130e3bb2b043f (diff)
downloaddjango-soc2010/query-refactor.tar.gz
[soc2010/query-refactor] Merged up to trunk r13556, resolved merge conflictsarchive/soc2010/query-refactorsoc2010/query-refactor
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13565 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/test/client.py')
-rw-r--r--django/test/client.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/test/client.py b/django/test/client.py
index e5a16b6e79..498af5c344 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -3,6 +3,7 @@ from urlparse import urlparse, urlunparse, urlsplit
import sys
import os
import re
+import mimetypes
try:
from cStringIO import StringIO
except ImportError:
@@ -138,11 +139,14 @@ def encode_multipart(boundary, data):
def encode_file(boundary, key, file):
to_str = lambda s: smart_str(s, settings.DEFAULT_CHARSET)
+ content_type = mimetypes.guess_type(file.name)[0]
+ if content_type is None:
+ content_type = 'application/octet-stream'
return [
'--' + boundary,
'Content-Disposition: form-data; name="%s"; filename="%s"' \
% (to_str(key), to_str(os.path.basename(file.name))),
- 'Content-Type: application/octet-stream',
+ 'Content-Type: %s' % content_type,
'',
file.read()
]