Author: ccahoon
Date: 2009-07-24 17:18:40 -0500 (Fri, 24 Jul 2009)
New Revision: 11327
Modified:
django/branches/soc2009/http-wsgi-improvements/django/conf/global_settings.py
django/branches/soc2009/http-wsgi-improvements/django/core/handlers/modpython.py
django/branches/soc2009/http-wsgi-improvements/django/core/handlers/wsgi.py
django/branches/soc2009/http-wsgi-improvements/django/http/__init__.py
django/branches/soc2009/http-wsgi-improvements/docs/howto/response-sendfile.txt
django/branches/soc2009/http-wsgi-improvements/docs/ref/request-response.txt
django/branches/soc2009/http-wsgi-improvements/docs/ref/settings.txt
Log:
[soc2009/http-wsgi-improvements] Change the setting name to SENDFILE_HEADER and
update docs. Refs #2131.
Modified:
django/branches/soc2009/http-wsgi-improvements/django/conf/global_settings.py
===================================================================
---
django/branches/soc2009/http-wsgi-improvements/django/conf/global_settings.py
2009-07-24 19:31:12 UTC (rev 11326)
+++
django/branches/soc2009/http-wsgi-improvements/django/conf/global_settings.py
2009-07-24 22:18:40 UTC (rev 11327)
@@ -242,7 +242,7 @@
# req.sendfile.
# Examples: 'X-Sendfile' (lighttpd & Cherokee with FastCGI/SCGI, Apache with
mod_xsendfile),
# 'X-Accel-Redirect' (nginx)
-HTTPRESPONSE_SENDFILE_HEADER = None
+SENDFILE_HEADER = None
# List of upload handler classes to be applied in order.
FILE_UPLOAD_HANDLERS = (
Modified:
django/branches/soc2009/http-wsgi-improvements/django/core/handlers/modpython.py
===================================================================
---
django/branches/soc2009/http-wsgi-improvements/django/core/handlers/modpython.py
2009-07-24 19:31:12 UTC (rev 11326)
+++
django/branches/soc2009/http-wsgi-improvements/django/core/handlers/modpython.py
2009-07-24 22:18:40 UTC (rev 11327)
@@ -204,9 +204,9 @@
req.sendfile(response.sendfile_filename)
else:
# If we are using a header to do sendfile, set the header and send
empty content
- if settings.RESPONSE_SENDFILE_HEADER:
+ if settings.SENDFILE_HEADER:
response.set_empty_content()
- response[settings.HTTPRESPONSE_SENDFILE_HEADER] =
response.sendfile_filename
+ response[settings.SENDFILE_HEADER] = response.sendfile_filename
for chunk in response:
req.write(chunk)
return 0 # mod_python.apache.OK
Modified:
django/branches/soc2009/http-wsgi-improvements/django/core/handlers/wsgi.py
===================================================================
--- django/branches/soc2009/http-wsgi-improvements/django/core/handlers/wsgi.py
2009-07-24 19:31:12 UTC (rev 11326)
+++ django/branches/soc2009/http-wsgi-improvements/django/core/handlers/wsgi.py
2009-07-24 22:18:40 UTC (rev 11327)
@@ -243,10 +243,9 @@
if isinstance(response, http.HttpResponseSendFile):
filename = response.sendfile_filename
- if settings.HTTPRESPONSE_SENDFILE_HEADER:
+ if settings.SENDFILE_HEADER:
response.set_empty_content()
- response_headers.append((settings.HTTPRESPONSE_SENDFILE_HEADER,
- filename))
+ response_headers.append((settings.SENDFILE_HEADER, filename))
elif 'wsgi.file_wrapper' in environ:
filelike = open(filename, 'rb')
return environ['wsgi.file_wrapper'](filelike,
Modified: django/branches/soc2009/http-wsgi-improvements/django/http/__init__.py
===================================================================
--- django/branches/soc2009/http-wsgi-improvements/django/http/__init__.py
2009-07-24 19:31:12 UTC (rev 11326)
+++ django/branches/soc2009/http-wsgi-improvements/django/http/__init__.py
2009-07-24 22:18:40 UTC (rev 11327)
@@ -447,7 +447,7 @@
self.block_size = block_size
self['Content-Disposition'] = ('attachment; filename=%s' %
os.path.basename(path_to_file))
- if not settings.HTTPRESPONSE_SENDFILE_HEADER and
os.path.exists(path_to_file):
+ if not settings.SENDFILE_HEADER and os.path.exists(path_to_file):
self['Content-Length'] = str(os.path.getsize(path_to_file))
self._empty_content = False
Modified:
django/branches/soc2009/http-wsgi-improvements/docs/howto/response-sendfile.txt
===================================================================
---
django/branches/soc2009/http-wsgi-improvements/docs/howto/response-sendfile.txt
2009-07-24 19:31:12 UTC (rev 11326)
+++
django/branches/soc2009/http-wsgi-improvements/docs/howto/response-sendfile.txt
2009-07-24 22:18:40 UTC (rev 11327)
@@ -52,7 +52,7 @@
sent through :func:`~django.http.HttpResponseSendFile` is defined inside its
configuration file. However,
in most other instances it is treated as the root of the server's file system.
-The header used is defined by the setting
:setting:`HTTPRESPONSE_SENDFILE_HEADER`. If it is
+The header used is defined by the setting :setting:`SENDFILE_HEADER`. If it is
left as a default, the fallback method will be used. Otherwise, it should be
set as a
string containing the header used by the server.
@@ -63,7 +63,7 @@
Apache supports efficient file transfer using ``mod_xsendfile_``. Once this
module is in
place, add the following line to ``settings.py``::
- HTTPRESPONSE_SENDFILE_HEADER = "X-Sendfile"
+ SENDFILE_HEADER = "X-Sendfile"
This will inform :func:`~django.http.HttpResponseSendFile` that it should
allow the server to handle serving
the file passed to it.
@@ -89,7 +89,7 @@
Add the following line to ``settings.py``::
- HTTPRESPONSE_SENDFILE_HEADER = "X-Sendfile"
+ SENDFILE_HEADER = "X-Sendfile"
How to use HttpResponseSendFile with Cherokee
@@ -105,7 +105,7 @@
Add the following line to ``settings.py``::
- HTTPRESPONSE_SENDFILE_HEADER = "X-Sendfile"
+ SENDFILE_HEADER = "X-Sendfile"
Then, follow the directions under General Use, above.
@@ -127,5 +127,5 @@
Add the following line to ``settings.py``::
- HTTPRESPONSE_SENDFILE_HEADER = "X-Accel-Redirect"
+ SENDFILE_HEADER = "X-Accel-Redirect"
Modified:
django/branches/soc2009/http-wsgi-improvements/docs/ref/request-response.txt
===================================================================
---
django/branches/soc2009/http-wsgi-improvements/docs/ref/request-response.txt
2009-07-24 19:31:12 UTC (rev 11326)
+++
django/branches/soc2009/http-wsgi-improvements/docs/ref/request-response.txt
2009-07-24 22:18:40 UTC (rev 11327)
@@ -585,7 +585,7 @@
optionally, the file's content type and block size hint for handlers that
need it.
- If the setting ``HTTPRESPONSE_SENDFILE_HEADER`` is overridden (default
None),
+ If the setting :setting:`SENDFILE_HEADER` is overridden (default None),
HttpResponseSendFile will return that response header set as the file name
given.
If the file is unavailable, no content will be returned. Since certain
servers
do not allow direct access to the file system, it is not feasible to verify
@@ -595,8 +595,7 @@
must be controlled, and performs no verification of a file's existence in
most
cases.
- Note that response middleware will be bypassed if you use
- :class:`HttpResponseSendFile`.
+ **Note:** Response middleware is bypassed by HttpResponseSendFile.
.. class:: HttpResponseRedirect
Modified: django/branches/soc2009/http-wsgi-improvements/docs/ref/settings.txt
===================================================================
--- django/branches/soc2009/http-wsgi-improvements/docs/ref/settings.txt
2009-07-24 19:31:12 UTC (rev 11326)
+++ django/branches/soc2009/http-wsgi-improvements/docs/ref/settings.txt
2009-07-24 22:18:40 UTC (rev 11327)
@@ -835,6 +835,21 @@
.. setting:: SERIALIZATION_MODULES
+SENDFILE_HEADER
+-----------------------------
+
+Default: ``None``
+
+If not ``None``, this defines the header that an
:func:`~django.http.HttpResponseSendFile`
+filename is put into, such as ``X-SendFile``. If it is set, the response's
content is
+blank, and the responsibility to send the file is left to the server.
+
+If ``None``, and the handler does not do anything special for
:func:`~django.http.HttpResponseSendFile`,
+then :func:`~django.http.HttpResponseSendFile` will behave like
:func:`~django.http.HttpResponse`,
+but ensure that the file gets closed.
+
+.. setting:: SENDFILE_HEADER
+
SERIALIZATION_MODULES
---------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---