File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,25 @@ func (r *responseWriterDelegator) Written() int64 {
5353}
5454
5555func (r * responseWriterDelegator ) WriteHeader (code int ) {
56- if r .observeWriteHeader != nil && ! r .wroteHeader {
57- // Only call observeWriteHeader for the 1st time. It's a bug if
58- // WriteHeader is called more than once, but we want to protect
59- // against it here. Note that we still delegate the WriteHeader
60- // to the original ResponseWriter to not mask the bug from it.
61- r .observeWriteHeader (code )
56+ if ! r .wroteHeader {
57+ // Ignore informational headers.
58+ // Based on https://github.com/golang/go/blob/go1.24.1/src/net/http/server.go#L1216
59+ if code >= 100 && code <= 199 && code != http .StatusSwitchingProtocols {
60+ goto propagate
61+ }
62+
63+ if r .observeWriteHeader != nil {
64+ // Only call observeWriteHeader for the 1st time. It's a bug if
65+ // WriteHeader is called more than once, but we want to protect
66+ // against it here. Note that we still delegate the WriteHeader
67+ // to the original ResponseWriter to not mask the bug from it.
68+ r .observeWriteHeader (code )
69+ }
6270 }
6371 r .status = code
6472 r .wroteHeader = true
73+
74+ propagate:
6575 r .ResponseWriter .WriteHeader (code )
6676}
6777
You can’t perform that action at this time.
0 commit comments