Skip to content
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

[Feature] Add proper support of Accept HTTP header #917

Closed
Shane32 opened this issue Aug 26, 2022 · 2 comments · Fixed by #919
Closed

[Feature] Add proper support of Accept HTTP header #917

Shane32 opened this issue Aug 26, 2022 · 2 comments · Fixed by #919

Comments

@Shane32
Copy link
Member

Shane32 commented Aug 26, 2022

If the request includes a supported response content type within the Accept header, the response content type should match the content type requested by the client.

See also:

Supported response content types should be:

  • application/json
  • application/graphql-response+json (current draft spec)
  • application/graphql+json (previous draft spec and v7.0 behavior) -- probably remove in some future version
@Shane32
Copy link
Member Author

Shane32 commented Aug 28, 2022

@sungam3r What do you think makes the most sense here:

Option 1

Assuming the requested content-type is supported, return exactly the content-type that was passed into the Accept header.

For example, when requesting APPLICATION/JSON, return APPLICATION/JSON and not application/json; charset=utf-8.

The accept header may return a wildcard, so in those situations we would need to pick an applicable content type.

Option 2

Try to find a best match, and return a compatible content-type with the request.

For example, when requesting APPLICATION/JSON, return application/json; charset=utf-8.

The ASP.NET-provided method for determining compatibility has changed across different versions of ASP.NET. In .NET 6, the same sample above would return application/graphql-response+json; charset=utf-8 because that is considered compatible (assuming of course that we gave priority to that response). We would need to decide to either (a) use the implementation provided by whatever version of .NET is in use, or (b) copy an implementation and use that.

Note that all versions from ASP.NET 2.1 through ASP.NET 6.0 do not support a quoted charset - e.g. charset="UTF-8".

@sungam3r
Copy link
Member

I tend to option 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants