File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,21 @@ 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 response status codes.
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+ r .ResponseWriter .WriteHeader (code )
61+ return
62+ }
63+
64+ if r .observeWriteHeader != nil {
65+ // Only call observeWriteHeader for the 1st time. It's a bug if
66+ // WriteHeader is called more than once, but we want to protect
67+ // against it here. Note that we still delegate the WriteHeader
68+ // to the original ResponseWriter to not mask the bug from it.
69+ r .observeWriteHeader (code )
70+ }
6271 }
6372 r .status = code
6473 r .wroteHeader = true
You can’t perform that action at this time.
0 commit comments