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

Closed
talglobus opened this issue Apr 2, 2021 · 2 comments

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.

@gopherbot gopherbot added this to the Unreleased milestone Apr 2, 2021
@talglobus talglobus changed the title x/net: net/http/httptest presents status codes that net/http will not send as sent net/http: net/http/httptest presents status codes that net/http will not send as sent Apr 2, 2021
@talglobus
Copy link
Author

Miscategorized upon initial issue, reopening with correct categorization

@talglobus
Copy link
Author

talglobus commented Apr 2, 2021

Replaced with #45353

@golang golang locked and limited conversation to collaborators Apr 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants