mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 04:57:07 +08:00
look through all Accept headers when negotiating
This commit is contained in:
parent
f1e942889a
commit
03df4383e2
@ -1100,7 +1100,9 @@ func (c *Context) NegotiateFormat(offered ...string) string {
|
|||||||
assert1(len(offered) > 0, "you must provide at least one offer")
|
assert1(len(offered) > 0, "you must provide at least one offer")
|
||||||
|
|
||||||
if c.Accepted == nil {
|
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 {
|
if len(c.Accepted) == 0 {
|
||||||
return offered[0]
|
return offered[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user