support XACCELREDIRECT

This commit is contained in:
j 2010-09-13 18:23:53 +02:00
parent aa7f808431
commit 309f889670
1 changed files with 6 additions and 1 deletions

View File

@ -12,7 +12,12 @@ def HttpFileResponse(path, content_type=None, filename=None):
raise Http404
if not content_type:
content_type = mimetypes.guess_type(path)[0]
if settings.XSENDFILE:
if hasattr(settings, 'XACCELREDIRECT') and settings.XACCELREDIRECT:
response = HttpResponse()
response['X-Accel-Redirect'] = path.replace(*settings.XACCELREDIRECT)
response['Content-Type'] = content_type
response['Content-Length'] = os.stat(path).st_size
elif settings.XSENDFILE:
response = HttpResponse()
response['X-Sendfile'] = path
response['Content-Type'] = content_type