@marcel91200 / caddy Mirror · read-only / commits / 11151586
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 12, 03:15 UTC

caddyhttp: ResponseRecorder sets stream regardless of 1xx

Fixes a panic where rr.stream is not true when it should be in the event of 1xx, because the buf is nil

Matthew Holt committed Jan 27, 2025 at 08:18 UTC 11151586165946453275b66ef33794d41a5e047b
1 file changed +7 -7
modules/caddyhttp/responsewriter.go
+7 -7
@@ -154,16 +154,16 @@ func (rr *responseRecorder) WriteHeader(statusCode int) {
154 // connections by manually setting headers and writing status 101
155 rr.statusCode = statusCode
156
157 + // decide whether we should buffer the response
158 + if rr.shouldBuffer == nil {
159 + rr.stream = true
160 + } else {
161 + rr.stream = !rr.shouldBuffer(rr.statusCode, rr.ResponseWriterWrapper.Header())
162 + }
163 +
164 // 1xx responses aren't final; just informational
165 if statusCode < 100 || statusCode > 199 {
166 rr.wroteHeader = true
160 -
161 - // decide whether we should buffer the response
162 - if rr.shouldBuffer == nil {
163 - rr.stream = true
164 - } else {
165 - rr.stream = !rr.shouldBuffer(rr.statusCode, rr.ResponseWriterWrapper.Header())
166 - }
167 }
168
169 // if informational or not buffered, immediately write header