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

Add accept header in case of a 415 error #2672

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

komape
Copy link
Contributor

@komape komape commented Oct 30, 2024

Motivation:

Refer to issue #2663 for additional context regarding this PR.

This update introduces an Accept header in the response for situations where an unmatched content type leads to a 415 error. The header specifies the accepted content types following the format outlined in RFC 9110:

<type>/<subtype>; <param_key>=<param_value>

Examples:

  • With parameters:
text/html; boo=ya
  • Without parameters (only MIME type):
text/html
text/*
*/json
  • Parameter present with no value:
text/html; boo
  • Multiple accepted content types (comma-separated), which may also include parameters:
text/html, application/json
text/html; boo=ya, application/json
  • Multiple parameters for the same content type listed separately:
text/html; boo=ya, text/html; works
  • If a parameter value contains special characters, it should be enclosed in double quotes:
text/html; boo="yeah, right"
  • If a parameter value contains a double quote, it must be escaped:
text/html; boo="yeah\"right"

This enhancement aims to improve content negotiation and provide clearer guidance to clients regarding acceptable content types.

This PR closes #2663.

@komape
Copy link
Contributor Author

komape commented Oct 30, 2024

@tsegismont Seems like the test are executed properly 👍 I'll try to fix the issues.

@komape komape marked this pull request as ready for review October 30, 2024 13:17
@komape
Copy link
Contributor Author

komape commented Nov 4, 2024

@tsegismont Let me know what you think of the values for the Accept header. The standard for it is not very precise on it and has some leeway in the design. I did what I think is the best but I'm open for opinions 😉

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

Successfully merging this pull request may close these issues.

Add Accept header to 415 reponses
1 participant