dont set None as content_type
This commit is contained in:
parent
c87a6eddba
commit
5e0193d149
1 changed files with 4 additions and 2 deletions
|
@ -24,11 +24,13 @@ def HttpFileResponse(path, content_type=None, filename=None):
|
||||||
if root and path.startswith(root):
|
if root and path.startswith(root):
|
||||||
path = url + path[len(root)+1:]
|
path = url + path[len(root)+1:]
|
||||||
response['X-Accel-Redirect'] = path
|
response['X-Accel-Redirect'] = path
|
||||||
response['Content-Type'] = content_type
|
if content_type:
|
||||||
|
response['Content-Type'] = content_type
|
||||||
elif getattr(settings, 'XSENDFILE', False):
|
elif getattr(settings, 'XSENDFILE', False):
|
||||||
response = HttpResponse()
|
response = HttpResponse()
|
||||||
response['X-Sendfile'] = path
|
response['X-Sendfile'] = path
|
||||||
response['Content-Type'] = content_type
|
if content_type:
|
||||||
|
response['Content-Type'] = content_type
|
||||||
response['Content-Length'] = os.stat(path).st_size
|
response['Content-Length'] = os.stat(path).st_size
|
||||||
else:
|
else:
|
||||||
response = HttpResponse(open(path), content_type=content_type)
|
response = HttpResponse(open(path), content_type=content_type)
|
||||||
|
|
Loading…
Reference in a new issue