Skip to content

Commit

Permalink
Introduced DownloadResponse.url. Not used yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitbryon committed Nov 28, 2012
1 parent 450d2f4 commit 66c83a8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions django_downloadview/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DownloadResponse(HttpResponse):
"""File download response."""
def __init__(self, content, content_type, content_length, basename,
status=200, content_encoding=None, expires=None,
filename=None):
filename=None, url=None):
"""Constructor.
It differs a bit from HttpResponse constructor.
Expand Down Expand Up @@ -35,8 +35,20 @@ def __init__(self, content, content_type, content_length, basename,
It is used to set the "Expires" header.
* ``filename`` is the server-side name of the file.
It may be used by decorators or middlewares to delegate the actual
streaming to a more efficient server (i.e. Nginx, Lighttpd...).
It may be used by decorators or middlewares.
* ``url`` is the actual URL of the file content.
* If Django is to serve the file, then ``url`` should be
``request.get_full_path()``. This should be the default behaviour
when ``url`` is None.
* If ``url`` is not None and differs from
``request.get_full_path()``, then it means that the actual download
should be performed at another location. In that case,
DownloadResponse doesn't return a redirection, but ``url`` may be
caught and used by download middlewares or decorators (Nginx,
Lighttpd...).
"""
super(DownloadResponse, self).__init__(content=content, status=status,
Expand Down

0 comments on commit 66c83a8

Please sign in to comment.