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

Skip to content

Regression in Content-Type response #36136

Closed
@alexander-schranz

Description

@alexander-schranz

Symfony version(s) affected: since 4.4.0

Description

Since #32344 the Content-Type is set on text/plain if the client request does only accept text/plain. This is an issue as the symfony http cache and varnish will also cache the Content-Type. So if a bot for example is the first one requesting the page it will get text/plain when now a normal user request the page in the browser he will also get text/plain and see the source code instead of a rendered html page.

How to reproduce

Have a symfony http cache or varnish in front:

First request:

curl -XGET "http://127.0.0.1:8000/?v=text-header" -H  "accept: text/plain"

# or a more strange error a xml:

curl -XGET "http://127.0.0.1:8000/?v=xml-header" -H  "accept: application/xml"

Now visit the page in a our browser:

The page will not be rendered as the Content-Type header is not text/html.

Possible Solution

I know I could set a Vary header but I think this behaviour should be reverted as its very tricky why you see now the source code of a page not its rendered html. Think this behaviour should only be changed in a major version.

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