gin icon indicating copy to clipboard operation
gin copied to clipboard

Multiple `Accept` header fix

Open tsmethurst opened this issue 1 year ago • 2 comments

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 avatar May 27 '22 14:05 tsmethurst

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

tsmethurst avatar May 16 '23 11:05 tsmethurst

@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.

daenney avatar May 16 '23 13:05 daenney