* support negotiation wildcards, fix #391 * fix typo
This commit is contained in:
13
context.go
13
context.go
@ -952,7 +952,18 @@ func (c *Context) NegotiateFormat(offered ...string) string {
|
||||
}
|
||||
for _, accepted := range c.Accepted {
|
||||
for _, offert := range offered {
|
||||
if accepted == offert {
|
||||
// According to RFC 2616 and RFC 2396, non-ASCII characters are not allowed in headers,
|
||||
// therefore we can just iterate over the string without casting it into []rune
|
||||
i := 0
|
||||
for ; i < len(accepted); i++ {
|
||||
if accepted[i] == '*' || offert[i] == '*' {
|
||||
return offert
|
||||
}
|
||||
if accepted[i] != offert[i] {
|
||||
break
|
||||
}
|
||||
}
|
||||
if i == len(accepted) {
|
||||
return offert
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user