diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-06-24 16:06:21 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-06-24 16:06:21 (GMT) |
commit | df289a8a409efa67c89d53ccba7c2e849666f1f5 (patch) | |
tree | ba992dfeb388b79dbc89294f1f1d3f513200f0c8 /src/rhimportd | |
parent | 633022fd6f9d4a2d5b715e2eaf452bb0d5097861 (diff) |
improved error responses on websocket control interface
Diffstat (limited to 'src/rhimportd')
-rw-r--r-- | src/rhimportd/ctrlWebSocket.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/rhimportd/ctrlWebSocket.go b/src/rhimportd/ctrlWebSocket.go index 4dd43a7..edd4b9d 100644 --- a/src/rhimportd/ctrlWebSocket.go +++ b/src/rhimportd/ctrlWebSocket.go @@ -329,7 +329,6 @@ func webSocketHandler(conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport t, r, err := ws.NextReader() if err != nil { rhdl.Println("WebSocket Client", ws.RemoteAddr(), "disconnected:", err) - // sendWebSocketErrorResponse(ws, http.StatusBadRequest, err.Error()) return } @@ -340,18 +339,20 @@ func webSocketHandler(conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport if err == io.EOF { err = io.ErrUnexpectedEOF } - rhdl.Println("WebSocket Client", ws.RemoteAddr(), "disconnected:", err) - // sendWebSocketErrorResponse(ws, http.StatusBadRequest, err.Error()) + rhdl.Println("WebSocket Client", ws.RemoteAddr(), "request error:", err) + sendWebSocketErrorResponse(ws, http.StatusBadRequest, err.Error()) return - } else { - // rhdl.Printf("Websocket Client %s got: %+v", ws.RemoteAddr(), reqdata) - reqchan <- *reqdata } + // rhdl.Printf("Websocket Client %s got: %+v", ws.RemoteAddr(), reqdata) + reqchan <- *reqdata case websocket.BinaryMessage: data, err := ioutil.ReadAll(r) if err != nil { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } rhdl.Println("WebSocket Client", ws.RemoteAddr(), "disconnected:", err) - // sendWebSocketErrorResponse(ws, http.StatusBadRequest, err.Error()) + sendWebSocketErrorResponse(ws, http.StatusInternalServerError, err.Error()) return } // rhdl.Printf("WebSocket Client %s: got binary message (%d bytes)", ws.RemoteAddr(), len(data)) |