Commit 64be3e41 authored by Matthew Holt's avatar Matthew Holt

websocket: Avoid multiple calls to WriteHeader if Upgrade fails

parent 643dac68
......@@ -86,7 +86,9 @@ func serveWS(w http.ResponseWriter, r *http.Request, config *Config) (int, error
}
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
return http.StatusBadRequest, err
// the connection has been "handled" -- WriteHeader was called with Upgrade,
// so don't return an error status code; just return an error
return 0, err
}
defer conn.Close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment