8000 minor #10579 Documented the HeaderUtils::makeDisposition() method (ja… · symfony/symfony-docs@b764813 · GitHub
[go: up one dir, main page]

Skip to content

Commit b764813

Browse files
committed
minor #10579 Documented the HeaderUtils::makeDisposition() method (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Documented the HeaderUtils::makeDisposition() method Fixes #10571. Commits ------- 4341e98 Documented the HeaderUtils::makeDisposition() method
2 parents 72a89f0 + 4341e98 commit b764813

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/http_foundation.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,22 +562,26 @@ Serving Files
562562
When sending a file, you must add a ``Content-Disposition`` header to your
563563
response. While creating this header for basic file downloads is easy, using
564564
non-ASCII filenames is more involving. The
565-
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::makeDisposition`
565+
:method:`Symfony\\Component\\HttpFoundation\\HeaderUtils::makeDisposition`
566566
abstracts the hard work behind a simple API::
567567

568+
use Symfony\Component\HttpFoundation\HeaderUtils;
568569
use Symfony\Component\HttpFoundation\Response;
569570
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
570571

571572
$fileContent = ...; // the generated file content
572573
$response = new Response($fileContent);
573574

574-
$disposition = $response->headers->makeDisposition(
575-
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
575+
$disposition = HeaderUtils::makeDisposition(
576+
HeaderUtils::DISPOSITION_ATTACHMENT,
576577
'foo.pdf'
577578
);
578579

579580
$response->headers->set('Content-Disposition', $disposition);
580581

582+
.. versionadded:: 4.2
583+
The static ``HeaderUtils::makeDisposition()`` method was introduced in Symfony 4.2.
584+
581585
Alternatively, if you are serving a static file, you can use a
582586
:class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse`::
583587

0 commit comments

Comments
 (0)
0