Skip to content

Commit

Permalink
[fix] 修改是否升级成websocket判断 兼容火狐浏览器
Browse files Browse the repository at this point in the history
火狐浏览器ws请求时 Connection = [keep-alive, Upgrade]
目前是根据RFC 6455标准例子判断Connection=Upgrade
会导致火狐浏览器ws升级失败
根据RFC 2616修改为Connection包含Upgrade即可
  • Loading branch information
cuteLittleDevil authored Aug 31, 2023
1 parent 6af11b2 commit 2263c7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/logic/http_server_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ func (h *HttpServerHandler) ServeSubSession(writer http.ResponseWriter, req *htt
isWebSocket bool
webSocketKey string
)
if req.Header.Get("Connection") == "Upgrade" && req.Header.Get("Upgrade") == "websocket" {
// 火狐浏览器 Connection = [keep-alive, Upgrade]
if strings.Contains(req.Header.Get("Connection"), "Upgrade") && req.Header.Get("Upgrade") == "websocket" {
isWebSocket = true
webSocketKey = req.Header.Get("Sec-WebSocket-Key")
}
Expand Down

0 comments on commit 2263c7f

Please sign in to comment.