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

net/http: export errCannotRewind #54173

Open
dillonstreator opened this issue Aug 1, 2022 · 4 comments · May be fixed by #54176
Open

net/http: export errCannotRewind #54173

dillonstreator opened this issue Aug 1, 2022 · 4 comments · May be fixed by #54176
Labels
NeedsInvestigation
Milestone

Comments

@dillonstreator
Copy link

dillonstreator commented Aug 1, 2022

var errCannotRewind = errors.New("net/http: cannot rewind body after connection loss")

I'm having to resort to string matching to identify this error which is not ideal

strings.Contains(err.Error(), "net/http: cannot rewind body after connection loss")

I'd love to just be able to use errors.Is

errors.Is(err, http.ErrCannotRewind)
@dillonstreator dillonstreator linked a pull request Aug 1, 2022 that will close this issue
@gopherbot
Copy link

gopherbot commented Aug 1, 2022

Change https://go.dev/cl/420574 mentions this issue: net/http: export errCannotRewind``

dillonstreator added a commit to dillonstreator/go that referenced this issue Aug 1, 2022
@neild
Copy link
Contributor

neild commented Aug 1, 2022

What is the use case for distinguishing this error?

@dillonstreator
Copy link
Author

dillonstreator commented Aug 1, 2022

What is the use case for distinguishing this error?

controlling a log level

@dmitshur dmitshur changed the title net/http export errCannotRewind net/http: export errCannotRewind Aug 2, 2022
@dmitshur dmitshur added the NeedsInvestigation label Aug 2, 2022
@dmitshur dmitshur added this to the Backlog milestone Aug 2, 2022
@neild
Copy link
Contributor

neild commented Aug 2, 2022

I don't think this is an error we want to expose. We generally only add distinguishable errors for conditions where code can make a meaningful choice depending on the type of error; this doesn't seem to be such a case.

If we did want to expose this condition, simply exporting errCannotRewind would not be sufficient, since it's only used by the HTTP/1 implementation.

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

Successfully merging a pull request may close this issue.

4 participants