Skip to content

Commit e075bf4

Browse files
fix: add Connection header validation to IsWebSocket() (RFC 6455)
1 parent 096ce41 commit e075bf4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

context.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ func (c *Context) IsTLS() bool {
153153
// IsWebSocket returns true if HTTP connection is WebSocket otherwise false.
154154
func (c *Context) IsWebSocket() bool {
155155
upgrade := c.request.Header.Get(HeaderUpgrade)
156-
return strings.EqualFold(upgrade, "websocket")
156+
connection := c.request.Header.Get(HeaderConnection)
157+
return strings.EqualFold(upgrade, "websocket") && strings.Contains(strings.ToLower(connection), "upgrade")
157158
}
158159

159160
// Scheme returns the HTTP protocol scheme, `http` or `https`.

0 commit comments

Comments
 (0)