look through all Accept headers when negotiating

This commit is contained in:
tsmethurst 2022-05-27 16:28:19 +02:00
parent f1e942889a
commit 03df4383e2

View File

@ -1100,7 +1100,9 @@ func (c *Context) NegotiateFormat(offered ...string) string {
assert1(len(offered) > 0, "you must provide at least one offer")
if c.Accepted == nil {
c.Accepted = parseAccept(c.requestHeader("Accept"))
for _, a := range c.Request.Header.Values("Accept") {
c.Accepted = append(c.Accepted, parseAccept(a)...)
}
}
if len(c.Accepted) == 0 {
return offered[0]