From 309f889670c39f214791fdfe62bcb4b11be2fbcf Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 13 Sep 2010 18:23:53 +0200 Subject: [PATCH] support XACCELREDIRECT --- oxdjango/http.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/oxdjango/http.py b/oxdjango/http.py index 2b7c0e7..aadea00 100644 --- a/oxdjango/http.py +++ b/oxdjango/http.py @@ -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