-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: ensure that a superfluous WriteHeader call panics in httptest #69440
base: master
Are you sure you want to change the base?
Conversation
This PR (HEAD: 562ba1c) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/612995. Important tips:
|
I considered logging first, but it appears nothing uses logs in that package (yet), and we do already have a |
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/612995. |
Message from Damien MATHIEU: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/612995. |
Message from Damien Neil: Patch Set 2: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/612995. |
Message from Damien MATHIEU: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/612995. |
Message from Damien MATHIEU: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/612995. |
Message from Ingo Oeser: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/612995. |
In net/http, using WriteHeader() twice creates a log entry, since the second one is superfluous:
https://cs.opensource.google/go/go/+/refs/tags/go1.23.1:src/net/http/server.go;l=1201
In net/http/httptest though, while a check is made, there is no way to detect the superfluous usage.
That makes superfluous calls reasy to reach production runtimes.
To help prevent that, this change proposes rejecting any superfluous WriteHeader calls in the httptest package.