fail WebSockets with subprotocols here, because gorilla leaves it up for us to deal with subprotocols

This commit is contained in:
Edmund Huber 2015-06-06 15:11:59 -07:00
parent 23d7c81684
commit 62302ec92e
1 changed files with 8 additions and 0 deletions

View File

@ -218,6 +218,14 @@ func (s *Server) wslisten(addr string) {
Log.error.Printf("%s method not allowed", s) Log.error.Printf("%s method not allowed", s)
return return
} }
// We don't have any subprotocols, so if someone attempts to `new
// WebSocket(server, "subprotocol")` they'll break here, instead of
// getting the default, ambiguous, response from gorilla.
if v, ok := r.Header["Sec-Websocket-Protocol"]; ok {
http.Error(w, fmt.Sprintf("WebSocket subprocotols (e.g. %s) not supported", v), 400)
}
ws, err := upgrader.Upgrade(w, r, nil) ws, err := upgrader.Upgrade(w, r, nil)
if err != nil { if err != nil {
Log.error.Printf("%s websocket upgrade error: %s", s, err) Log.error.Printf("%s websocket upgrade error: %s", s, err)