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

Multiple Accept header fix #3156

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

Conversation

tsmethurst
Copy link

This PR updates Accept content negotiation to iterate through multiple Accept headers to find possible negotiable formats, rather than just taking the first Accept header and ignoring the others.

@tsmethurst
Copy link
Author

Hello! Can this be merged? It's still pretty useful imo :)

@daenney
Copy link

daenney commented May 16, 2023

@thinkerou @appleboy Would it be possible to get some eyes on this one?

It's very easy to run into this situation. When using the Go and preparing a request people might easily call req.Header.Add("Accept", ...) multiple times instead of concatenating the values with a ,, and on the command line people are very likely to use -H "Accept: ..." repeatedly with cURL instead of building the string by hand.

Based on my reading of the RFC, any field that accepts a comma separated list can also be represented as the same field multiple times. Given Accept is a list, Gin should understand both.

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 this pull request may close these issues.

2 participants