net/http: checking if http.Hijacker was already Hijacked without writing http.StatusOK #20331
Labels
Comments
Sorry, that would be too big of a breaking change for others. You might be interested in #18997 which would provide a way for you to get the info you want. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?macOS, amd64
What did you do?
I'm writing HTTP middleware that can check if underlying connection hijacked or not,
and if not - close connection with specific header and payload.
In go1.8 @bradfitz added some functionality to check if connection is hijacked without
unnecessary logs spam (#16456).
However, if connection is not hijacked, after call
_, err := w.Write(nil)
http.StatusOK is written automatically, so it's not possible to write any other header.
https://play.golang.org/p/LBnyyyijlk
So may be we can modify Write call to check
if lenData == 0
beforeif !w.wroteHeader
?Or we need hijack checking interface anyway.
What did you expect to see?
nothing in logs
What did you see instead?
http: multiple response.WriteHeader calls
The text was updated successfully, but these errors were encountered: