MCPcopy
hub / github.com/gin-gonic/gin / IsWebsocket

Method IsWebsocket

context.go:1042–1048  ·  view source on GitHub ↗

IsWebsocket returns true if the request headers indicate that a websocket handshake is being initiated by the client.

()

Source from the content-addressed store, hash-verified

1040// IsWebsocket returns true if the request headers indicate that a websocket
1041// handshake is being initiated by the client.
1042func (c *Context) IsWebsocket() bool {
1043 if strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") &&
1044 strings.EqualFold(c.requestHeader("Upgrade"), "websocket") {
1045 return true
1046 }
1047 return false
1048}
1049
1050func (c *Context) requestHeader(key string) string {
1051 return c.Request.Header.Get(key)

Callers 1

TestWebsocketsRequiredFunction · 0.80

Calls 1

requestHeaderMethod · 0.95

Tested by 1

TestWebsocketsRequiredFunction · 0.64