gin
gin copied to clipboard
Multiple `Accept` header fix
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.
Hello! Can this be merged? It's still pretty useful imo :)
@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.