mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-23 00:56:45 +01:00
websocket: Avoid multiple calls to WriteHeader if Upgrade fails
This commit is contained in:
parent
643dac688c
commit
64be3e410c
1 changed files with 3 additions and 1 deletions
|
@ -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 a new issue