Right now, if a x/net/websocket client connects to an HTTP endpoint and receives a response with any status other than 101, it returns an ErrBadStatus (source). This error does not include the actual status code received, and so users of this library are unable to distinguish between, for instance, 403 Forbidden and 500 Internal Server Error responses.
One solution would be to add a websocket.HTTPStatusError which implements websocket.ProtocolError and also includes an exported Status field. This way, users could (if they wished) check the type of the error and switch on the Status field to determine correct behavior.
Right now, if a
x/net/websocket
client connects to an HTTP endpoint and receives a response with any status other than 101, it returns anErrBadStatus
(source). This error does not include the actual status code received, and so users of this library are unable to distinguish between, for instance, 403 Forbidden and 500 Internal Server Error responses.One solution would be to add a
websocket.HTTPStatusError
which implementswebsocket.ProtocolError
and also includes an exportedStatus
field. This way, users could (if they wished) check the type of the error and switch on theStatus
field to determine correct behavior.