mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 05:42:09 +08:00
IsWebsocket func return
This commit is contained in:
parent
de2418d345
commit
e5311338d1
@ -814,11 +814,8 @@ func (c *Context) ContentType() string {
|
||||
// IsWebsocket returns true if the request headers indicate that a websocket
|
||||
// handshake is being initiated by the client.
|
||||
func (c *Context) IsWebsocket() bool {
|
||||
if strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") &&
|
||||
strings.EqualFold(c.requestHeader("Upgrade"), "websocket") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") &&
|
||||
strings.EqualFold(c.requestHeader("Upgrade"), "websocket")
|
||||
}
|
||||
|
||||
func (c *Context) requestHeader(key string) string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user