Skip to content

Commit 3e5ab0b

Browse files
committed
[soc2009/http-wsgi-improvements] Fix HttpResponseSendFile indentation issue and set its initial content to be an empty string, for compatibility with ticket refs django#6527.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/http-wsgi-improvements@11261 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent a873df6 commit 3e5ab0b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

django/http/__init__.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,18 @@ class HttpResponseSendFile(HttpResponse):
442442
sendfile_fh = None
443443

444444
def __init__(self, path_to_file, content_type=None, block_size=8192):
445-
if not content_type:
446-
from mimetypes import guess_type
447-
content_type = guess_type(path_to_file)[0]
448-
if content_type is None:
449-
content_type = "application/octet-stream"
450-
super(HttpResponseSendFile, self).__init__(None,
451-
content_type=content_type)
452-
self.sendfile_filename = path_to_file
453-
self.block_size = block_size
454-
self['Content-Length'] = os.path.getsize(path_to_file)
455-
self['Content-Disposition'] = ('attachment; filename=%s' %
456-
os.path.basename(path_to_file))
457-
self[settings.HTTPRESPONSE_SENDFILE_HEADER] = path_to_file
445+
if not content_type:
446+
from mimetypes import guess_type
447+
content_type = guess_type(path_to_file)[0]
448+
if content_type is None:
449+
content_type = "application/octet-stream"
450+
super(HttpResponseSendFile, self).__init__('', content_type=content_type)
451+
self.sendfile_filename = path_to_file
452+
self.block_size = block_size
453+
self['Content-Length'] = os.path.getsize(path_to_file)
454+
self['Content-Disposition'] = ('attachment; filename=%s' %
455+
os.path.basename(path_to_file))
456+
self[settings.HTTPRESPONSE_SENDFILE_HEADER] = path_to_file
458457

459458
def __iter__(self):
460459
from django.core.servers.basehttp import FileWrapper

0 commit comments

Comments
 (0)