Skip to content

[RFC][DX][HttpFoundation] Make ResponseHeaderBag::makeDisposition static #27851

Closed
@BoShurik

Description

@BoShurik

Description
Usually we know all the headers while creating Response instance. In case of disposition we can't add it at this time

Example

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

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

$disposition = $response->headers->makeDisposition(
    ResponseHeaderBag::DISPOSITION_ATTACHMENT,
    'foo.pdf'
);

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

return $response;

vs

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

$fileContent = ...; // the generated file content

return new Response($fileContent, 200, [
    'Content-Disposition' => ResponseHeaderBag::makeDisposition(
        ResponseHeaderBag::DISPOSITION_ATTACHMENT,
        'foo.pdf'
    )
]);

There is issue #14504, but maybe we can implement it in 5.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions