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:
parent
23d7c81684
commit
62302ec92e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user