File tree 1 file changed +16
-6
lines changed
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 {
53
53
}
54
54
55
55
func (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
+ }
62
70
}
63
71
r .status = code
64
72
r .wroteHeader = true
73
+
74
+ propagate:
65
75
r .ResponseWriter .WriteHeader (code )
66
76
}
67
77
You can’t perform that action at this time.
0 commit comments