Skip to content

Commit f1d43af

Browse files
raju-mechatronicsaldas
authored andcommitted
fix: add Connection header validation to IsWebSocket() (RFC 6455)
1 parent 3205495 commit f1d43af

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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)