mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +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
|
// 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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user