Skip to content

Commit

Permalink
- fix websocket upgrade header judge
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal committed Jul 25, 2021
1 parent fa456ed commit b874dee
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions nbhttp/websocket/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,25 @@ func checkSameOrigin(r *http.Request) bool {
}

func headerContains(header http.Header, name string, value string) bool {
value = strings.ToLower(value)
for _, v := range header[name] {
if strings.ToLower(v) == value {
return true
t := ""
values := header[name]
for _, s := range values {
for {
t, s = nextToken(skipSpace(s))
if t == "" {
continue
}
s = skipSpace(s)
if s != "" && s[0] != ',' {
continue
}
if equalASCIIFold(t, value) {
return true
}
if s == "" {
continue
}
s = s[1:]
}
}
return false
Expand Down

0 comments on commit b874dee

Please sign in to comment.