3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 07:29:31 +01:00

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

View File

@ -218,6 +218,14 @@ func (s *Server) wslisten(addr string) {
Log.error.Printf("%s method not allowed", s)
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)
if err != nil {
Log.error.Printf("%s websocket upgrade error: %s", s, err)