Browse Source

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

tags/v0.1.0
Edmund Huber 9 years ago
parent
commit
62302ec92e
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      irc/server.go

+ 8
- 0
irc/server.go View File

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

Loading…
Cancel
Save