x/net/websocket: ErrBadStatus should include the bad status code #13528
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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.The text was updated successfully, but these errors were encountered: