@@ -409,7 +409,7 @@ represented by a PHP callable instead of a string::
409
409
.. _component-http-foundation-serving-files :
410
410
411
411
Serving Files
412
- ~~~~~~~~~~~~~~~~~
412
+ ~~~~~~~~~~~~~
413
413
414
414
.. versionadded :: 2.1
415
415
The ``makeDisposition `` method was added in Symfony 2.1.
@@ -427,7 +427,8 @@ abstracts the hard work behind a simple API::
427
427
$response->headers->set('Content-Disposition', $d);
428
428
429
429
.. versionadded :: 2.2
430
- The :class: `Symfony\\ Component\\ HttpFoundation\\ BinaryFileResponse ` class was added in Symfony 2.2.
430
+ The :class: `Symfony\\ Component\\ HttpFoundation\\ BinaryFileResponse `
431
+ class was added in Symfony 2.2.
431
432
432
433
Alternatively, if you are serving a static file, you can use a
433
434
:class: `Symfony\\ Component\\ HttpFoundation\\ BinaryFileResponse `::
@@ -437,10 +438,9 @@ Alternatively, if you are serving a static file, you can use a
437
438
$file = 'path/to/file.txt';
438
439
$response = new BinaryFileResponse($file);
439
440
440
- The :class: `Symfony\\ Component\\ HttpFoundation\\ BinaryFileResponse ` will
441
- automatically handle ``Range `` and ``If-Range `` headers from the request.
442
- You can also set the ``Content-Type `` of the sent file, or change its
443
- ``Content-Disposition ``::
441
+ The ``BinaryFileResponse `` will automatically handle ``Range `` and
442
+ ``If-Range `` headers from the request. You can also set the ``Content-Type ``
443
+ of the sent file, or change its ``Content-Disposition ``::
444
444
445
445
$response->headers->set('Content-Type', 'text/plain')
446
446
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'filename.txt');
@@ -464,7 +464,8 @@ right content and headers. A JSON response might look like this::
464
464
$response->headers->set('Content-Type', 'application/json');
465
465
466
466
.. versionadded :: 2.1
467
- The :class: `Symfony\\ Component\\ HttpFoundation\\ JsonResponse ` class was added in Symfony 2.1.
467
+ The :class: `Symfony\\ Component\\ HttpFoundation\\ JsonResponse `
468
+ class was added in Symfony 2.1.
468
469
469
470
There is also a helpful :class: `Symfony\\ Component\\ HttpFoundation\\ JsonResponse `
470
471
class, which can make this even easier::
0 commit comments