fix: fix upgrade header detect (#2134)

This commit is contained in:
Kr328 2022-05-15 09:12:53 +08:00 committed by 世界
parent c3f4e1ba2e
commit d3503ff940
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -15,7 +15,15 @@ import (
)
func isUpgradeRequest(req *http.Request) bool {
return strings.EqualFold(req.Header.Get("Connection"), "Upgrade")
for _, header := range req.Header["Connection"] {
for _, elm := range strings.Split(header, ",") {
if strings.EqualFold(strings.TrimSpace(elm), "Upgrade") {
return true
}
}
}
return false
}
func handleUpgrade(localConn net.Conn, source net.Addr, request *http.Request, in chan<- C.ConnContext) (resp *http.Response) {