Improve a couple of JSON-RPC server err conditions.
- When invalid HTTP Basic Access Authentication details are provided to the websocket endpoint, return a WWW-Authenticate header just like the non-websocket endpoint - When a connection to the websocket endpoint fails to properly upgrade, return a 400 Bad Request HTTP error status code
This commit is contained in:
parent
7b849ef3eb
commit
c0c48e0efd
1 changed files with 2 additions and 1 deletions
|
@ -3286,7 +3286,7 @@ func (s *rpcServer) Start() {
|
|||
rpcServeMux.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
|
||||
authenticated, err := s.checkAuth(r, false)
|
||||
if err != nil {
|
||||
http.Error(w, "401 Unauthorized.", http.StatusUnauthorized)
|
||||
jsonAuthFail(w)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3298,6 +3298,7 @@ func (s *rpcServer) Start() {
|
|||
rpcsLog.Errorf("Unexpected websocket error: %v",
|
||||
err)
|
||||
}
|
||||
http.Error(w, "400 Bad Request.", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
s.WebsocketHandler(ws, r.RemoteAddr, authenticated)
|
||||
|
|
Loading…
Reference in a new issue