Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Nginx X-HTTP-ACCEL header #1

Closed
benoitbryon opened this issue Aug 28, 2012 · 1 comment
Closed

Support Nginx X-HTTP-ACCEL header #1

benoitbryon opened this issue Aug 28, 2012 · 1 comment
Labels

Comments

@benoitbryon
Copy link
Collaborator

See http://wiki.nginx.org/X-accel and http://wiki.nginx.org/XSendfile

Here is a raw implementation, to give an idea...

def XAccelRedirectResponse(url, basename=None):
    """Return a HttpResponse with header for Nginx X-Accel-Redirect."""
    response = HttpResponse()
    basename = basename or url.split('/')[-1]
    response['X-Accel-Redirect'] = url
    response['Content-Type'] = ""
    response['Content-Disposition'] = 'attachment; filename=%s' % basename
    response['Expires'] = datetime.today() + timedelta(days=1)
    return response

The response class may support all headers supported by Nginx.

@benoitbryon
Copy link
Collaborator Author

Right now, I don't know what is the best way to configure DownloadView with Nginx X-Accel...

Inheritance and class methods (i.e. DownloadMixin.x_accel_response(...)) may not be the best choice, since it would mean that DownloadMixin has to support variations for many http servers (nginx, lighttpd, apache...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant