MCPcopy
hub / github.com/gorilla/websocket / Subprotocols

Function Subprotocols

server.go:311–321  ·  view source on GitHub ↗

Subprotocols returns the subprotocols requested by the client in the Sec-Websocket-Protocol header.

(r *http.Request)

Source from the content-addressed store, hash-verified

309// Subprotocols returns the subprotocols requested by the client in the
310// Sec-Websocket-Protocol header.
311func Subprotocols(r *http.Request) []string {
312 h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol"))
313 if h == "" {
314 return nil
315 }
316 protocols := strings.Split(h, ",")
317 for i := range protocols {
318 protocols[i] = strings.TrimSpace(protocols[i])
319 }
320 return protocols
321}
322
323// IsWebSocketUpgrade returns true if the client requested upgrade to the
324// WebSocket protocol.

Callers 3

selectSubprotocolMethod · 0.85
ServeHTTPMethod · 0.85
TestSubprotocolsFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by 2

ServeHTTPMethod · 0.68
TestSubprotocolsFunction · 0.68