Description
Description
100 Continue
response can be issued many times before an actual response is return (eg. 200 OK
). In case of otelhttp
these responses should be ignored.
When you look at the http/server.go
: https://github.com/golang/go/blob/go1.24.1/src/net/http/server.go#L1212-L1228 you can notice that they only set wroteHeader
variable or status
when it is not informational header.
But here https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/net/http/otelhttp/internal/request/resp_writer_wrapper.go#L62-L84 we don't filter 100 Continue
response.
Therefore, when 100 Continue
is set and then there is no explicit 200 OK
reported, then final status code will be 100
and not 200
as it should be.
Environment
- OS: MacOS
- Architecture: arch64
- Go Version: 1.24
otelhttp
version: v0.56.0
Steps To Reproduce
- Use following handler:
targetHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusContinue) // Explicitly inform client that we are ready for body. body, _ := io.ReadAll(r.Body) w.Write(body) }) http.Handle("/target", otelhttp.NewHandler(targetHandler, "target"))
- Run the code.
- Handler will report
100 Continue
header as final status code instead of200 OK
.
Expected behavior
200 OK
status code to be reported even when there is explicit 100 Continue
done in the handler.
Likely we need to do similar thing that they do in http/server.go
which is to simply ignore informational headers if they are issued before a regular response.
Metadata
Metadata
Assignees
Type
Projects
Status