Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BoShurik opened this issue Jul 5, 2018 · 2 comments
Closed

Comments

@BoShurik
Copy link
Contributor

BoShurik commented Jul 5, 2018

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

@nicolas-grekas
Copy link
Member

Making it static would be a BC break, but maybe adding it to the HeaderUtils class would work?
Up to give it a try and submit a PR?

@BoShurik
Copy link
Contributor Author

BoShurik commented Sep 7, 2018

I'll try

@fabpot fabpot closed this as completed Oct 15, 2018
fabpot added a commit that referenced this issue Oct 15, 2018
…on static (fabpot)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[HttpFoundation] Make ResponseHeaderBag::makeDisposition static

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes-ish
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes
| Fixed tickets | #27851
| License       | MIT
| Doc PR        | n/a

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Commits
-------

d29b410 [HttpFoundation] made ResponseHeaderBag::makeDisposition static
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants