diff options
Diffstat (limited to 'django/test/client.py')
-rw-r--r-- | django/test/client.py | 6 |
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() ] |