Permalink
Browse files

[#2416] Proofreading the new BinaryFileResponse and talking about X-S…

…endfile
  • Loading branch information...
1 parent 71de41a commit 615a7b3f32b374cf87c7e71deb200767bd92c790 @weaverryan weaverryan committed Apr 4, 2013
Showing with 12 additions and 3 deletions.
  1. +1 −1 book/controller.rst
  2. +11 −2 components/http_foundation/introduction.rst
View
@@ -731,7 +731,7 @@ headers and content that's sent back to the client::
- For JSON, there is :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`.
See :ref:`component-http-foundation-json-response`.
- For files, there is :class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse`.
- See :ref:`component-http-foundation-serving-files
+ See :ref:`component-http-foundation-serving-files`.
.. index::
single: Controller; Request object
@@ -439,8 +439,15 @@ Alternatively, if you are serving a static file, you can use a
$response = new BinaryFileResponse($file);
The ``BinaryFileResponse`` will automatically handle ``Range`` and
-``If-Range`` headers from the request. You can also set the ``Content-Type``
-of the sent file, or change its ``Content-Disposition``::
+``If-Range`` headers from the request. It also supports ``X-Sendfile``
+(see for `Nginx`_ and `Apache`_). To make use of it, you need to determine
+whether or not the ``X-Sendfile-Type`` header should be trusted and call
+:method:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse::trustXSendfileTypeHeader`
+if it should::
+
+ $response::trustXSendfileTypeHeader();
+
+You can still set the ``Content-Type`` of the sent file, or change its ``Content-Disposition``::
$response->headers->set('Content-Type', 'text/plain')
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'filename.txt');
@@ -496,3 +503,5 @@ Session
The session information is in its own document: :doc:`/components/http_foundation/sessions`.
.. _Packagist: https://packagist.org/packages/symfony/http-foundation
+.. _Nginx: http://wiki.nginx.org/XSendfile
+.. _Apache: https://tn123.org/mod_xsendfile/

0 comments on commit 615a7b3

Please sign in to comment.