Skip to content

Profiler doesn't show the response modified by AbstractSessionListener. #36846

@marcw

Description

@marcw

Symfony version(s) affected: 5.0 & 4.4

Description

When the AbstractSessionListener modifies the Response Cache-Control headers automatically, it is not reflected in the Symfony Profiler.

Example controller:

    /**
     * @Route("/bug", name="demo")
     */
    public function index()
    {
        $response = new BinaryFileResponse(__FILE__, 200);

        $response->setPublic();
        $response->headers->addCacheControlDirective("immutable");
        $response->setMaxAge(3600);

        return $response;
    }

Resulting curl command on the controller:

$ curl -I https://127.0.0.1:8000/bug
HTTP/2 200
accept-ranges: bytes
cache-control: immutable, max-age=0, must-revalidate, private
content-type: text/x-php;charset=UTF-8
date: Sun, 17 May 2020 12:07:36 GMT
expires: Sun, 17 May 2020 12:07:36 GMT
last-modified: Sun, 17 May 2020 11:54:28 GMT
x-debug-token: c914a6
x-debug-token-link: https://127.0.0.1:8000/_profiler/c914a6
x-powered-by: PHP/7.4.5
x-robots-tag: noindex
content-length: 571

What is shown in the Profiler Response tab:
Screenshot 2020-05-17 at 14 09 14

How to reproduce

A reproducer is available here: https://github.com/marcw/reproducer-symfony-bug-http-response-profiler.

Please:

  • Run symfony serve
  • Run curl -I https://localhost:8000/bug
  • Open https://127.0.0.1:8000/_profiler/latest?limit=10 and go to the Response tab.

Possible Solution

A possible solution was PR #36789 but it is in the process of being reverted (See #36838) as it caused the Debug toolbar to disappear (See #36836).

Another solution would be to ease the debugging when the Response is modified. A warning in the logs would be helpful as well.

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