Commits

cca...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 1d55ce8

[soc2009/http-wsgi-improvements] Change the setting name to SENDFILE_HEADER and update docs. Refs #2131.

  • Participants
  • Parent commits 2334589
  • Branches soc2009/http-wsgi-improvements

Comments (0)

Files changed (7)

File django/conf/global_settings.py

 # 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 = (

File django/core/handlers/modpython.py

             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

File django/core/handlers/wsgi.py

         
         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, 

File django/http/__init__.py

         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
 

File docs/howto/response-sendfile.txt

 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.
 
 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.
 
 Add the following line to ``settings.py``::
 
-    HTTPRESPONSE_SENDFILE_HEADER = "X-Sendfile"
+    SENDFILE_HEADER = "X-Sendfile"
 
 
 How to use HttpResponseSendFile with Cherokee
 
 Add the following line to ``settings.py``::
 
-    HTTPRESPONSE_SENDFILE_HEADER = "X-Sendfile"
+    SENDFILE_HEADER = "X-Sendfile"
 
 Then, follow the directions under General Use, above.
 
 
 Add the following line to ``settings.py``::
 
-    HTTPRESPONSE_SENDFILE_HEADER = "X-Accel-Redirect"
+    SENDFILE_HEADER = "X-Accel-Redirect"
 

File docs/ref/request-response.txt

     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
     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
 

File docs/ref/settings.txt

 
 .. 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
 ---------------------