Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/websocket: ErrBadStatus should include the bad status code #13528

Open
noahlt opened this issue Dec 8, 2015 · 1 comment
Open

x/net/websocket: ErrBadStatus should include the bad status code #13528

noahlt opened this issue Dec 8, 2015 · 1 comment
Milestone

Comments

@noahlt
Copy link

noahlt commented Dec 8, 2015

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.

@mikioh mikioh changed the title x/net/websocket.ErrBadStatus should include the bad status code x/net/websocket: ErrBadStatus should include the bad status code Dec 8, 2015
@rsc rsc added this to the Unreleased milestone Dec 28, 2015
@crewjam
Copy link

crewjam commented Jun 9, 2020

I have a use case where it would be handy to have the entire http response. Perhaps something along the lines of x/oauth2.RetrieveError ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants