websocket icon indicating copy to clipboard operation
websocket copied to clipboard

Please return different error when server responds with non-101 status code

Open sirzooro opened this issue 2 years ago • 1 comments

fasthttp/websocket module returns "websocket: bad handshake" error when HTTP response code is different than 101 or header values are incorrect. This hides any other non-websocket HTTP errors like 401 Unauthorized, 404 Not Found, 500 Internal Server Error, etc. Recently I was debugging one such issue and had to modify fasthttp/websocket to see what was wrong. Please add new error to report non-101 response from server. Make sure to allow getting HTTP status code from error - some errors may need special handling beside logging, e.g. prompt user for credentials when server returns 401 Unauthorized.

https://github.com/fasthttp/websocket/blob/master/client.go#L393-L396

sirzooro avatar Apr 08 '23 08:04 sirzooro

Hi @sirzooro,

Could you make a PR to fix that?. Please!

Sorry for my delayed answer!

savsgio avatar Jul 18 '23 12:07 savsgio