From 3e5ab0b8ec6d3c7527115704eccac3938b71496e Mon Sep 17 00:00:00 2001 From: Chris Cahoon Date: Fri, 17 Jul 2009 11:47:54 +0000 Subject: [PATCH] [soc2009/http-wsgi-improvements] Fix HttpResponseSendFile indentation issue and set its initial content to be an empty string, for compatibility with ticket refs #6527. git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/http-wsgi-improvements@11261 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/http/__init__.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/django/http/__init__.py b/django/http/__init__.py index 049f9420e5..d0303639b6 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -442,19 +442,18 @@ class HttpResponseSendFile(HttpResponse): sendfile_fh = None def __init__(self, path_to_file, content_type=None, block_size=8192): - if not content_type: - from mimetypes import guess_type - content_type = guess_type(path_to_file)[0] - if content_type is None: - content_type = "application/octet-stream" - super(HttpResponseSendFile, self).__init__(None, - content_type=content_type) - self.sendfile_filename = path_to_file - self.block_size = block_size - self['Content-Length'] = os.path.getsize(path_to_file) - self['Content-Disposition'] = ('attachment; filename=%s' % - os.path.basename(path_to_file)) - self[settings.HTTPRESPONSE_SENDFILE_HEADER] = path_to_file + if not content_type: + from mimetypes import guess_type + content_type = guess_type(path_to_file)[0] + if content_type is None: + content_type = "application/octet-stream" + super(HttpResponseSendFile, self).__init__('', content_type=content_type) + self.sendfile_filename = path_to_file + self.block_size = block_size + self['Content-Length'] = os.path.getsize(path_to_file) + self['Content-Disposition'] = ('attachment; filename=%s' % + os.path.basename(path_to_file)) + self[settings.HTTPRESPONSE_SENDFILE_HEADER] = path_to_file def __iter__(self): from django.core.servers.basehttp import FileWrapper