Subprotocols returns the subprotocols requested by the client in the Sec-Websocket-Protocol header.
(r *http.Request)
| 309 | // Subprotocols returns the subprotocols requested by the client in the |
| 310 | // Sec-Websocket-Protocol header. |
| 311 | func 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. |