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

Method selectSubprotocol

server.go:101–115  ·  view source on GitHub ↗
(r *http.Request, responseHeader http.Header)

Source from the content-addressed store, hash-verified

99}
100
101func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
102 if u.Subprotocols != nil {
103 clientProtocols := Subprotocols(r)
104 for _, serverProtocol := range u.Subprotocols {
105 for _, clientProtocol := range clientProtocols {
106 if clientProtocol == serverProtocol {
107 return clientProtocol
108 }
109 }
110 }
111 } else if responseHeader != nil {
112 return responseHeader.Get("Sec-Websocket-Protocol")
113 }
114 return ""
115}
116
117// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
118//

Callers 1

UpgradeMethod · 0.95

Calls 2

SubprotocolsFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected