IsWebsocket func return

This commit is contained in:
daheige 2021-06-05 10:48:13 +08:00
parent de2418d345
commit e5311338d1

View File

@ -814,11 +814,8 @@ func (c *Context) ContentType() string {
// IsWebsocket returns true if the request headers indicate that a websocket // IsWebsocket returns true if the request headers indicate that a websocket
// handshake is being initiated by the client. // handshake is being initiated by the client.
func (c *Context) IsWebsocket() bool { func (c *Context) IsWebsocket() bool {
if strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") && return strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") &&
strings.EqualFold(c.requestHeader("Upgrade"), "websocket") { strings.EqualFold(c.requestHeader("Upgrade"), "websocket")
return true
}
return false
} }
func (c *Context) requestHeader(key string) string { func (c *Context) requestHeader(key string) string {