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/httptest presents status codes that net/http will not send as sent #45353

Closed
talglobus opened this issue Apr 2, 2021 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@talglobus
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.16 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Applies to all operating systems and architectures

What did you do?

Used net/http/httptest to test a net/http server.

What did you expect to see?

Behavior from net/http/httptest accurately reflects that of net/http.

What did you see instead?

When an HTTP status code is provided to net/http's response.WriteHeader which is outside of the range 100 to 999, inclusive, a panic is documented to occur as intended behavior. This is documented here, which is called from response.WriteHeader.

When an HTTP status code is provided to net/http/httptest's response.WriteHeader, it is stored as successfully sent for later access regardless of whether the status code falls outside the 100 to 999 range. This is documented here.

The ResponseRecorder exposed by net/http/httptest is inconsistent with the net/http behavior it is designed to test.

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 2, 2021
@networkimprov
Copy link

cc @bradfitz @neild @fraenkel

@gopherbot
Copy link

Change https://golang.org/cl/308950 mentions this issue: net/http/httptest: check the HeaderCode when WriteHeader

@odeke-em odeke-em added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 12, 2021
@odeke-em odeke-em added this to the Backlog milestone Apr 12, 2021
@odeke-em odeke-em changed the title net/http: net/http/httptest presents status codes that net/http will not send as sent net/http/httptest presents status codes that net/http will not send as sent Apr 12, 2021
@golang golang locked and limited conversation to collaborators Apr 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants