mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-18 14:12:46 +08:00
websocket: Avoid multiple calls to WriteHeader if Upgrade fails
This commit is contained in:
parent
643dac688c
commit
64be3e410c
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user