@marcel91200 / caddy Mirror · read-only / commits / 9be4f194
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, 10:45 UTC

caddyhttp: Write header if needed in responseRecorder.WriteResponse (#6380)

Andreas Kohn committed Jun 7, 2024 at 15:25 UTC 9be4f194e036dddd4704a851fd15a9682d9e813d
1 file changed +4 -4
modules/caddyhttp/responsewriter.go
+4 -4
@@ -219,13 +219,13 @@ func (rr *responseRecorder) Buffered() bool {
219 }
220
221 func (rr *responseRecorder) WriteResponse() error {
222 - if rr.stream {
223 - return nil
224 - }
222 if rr.statusCode == 0 {
223 // could happen if no handlers actually wrote anything,
224 // and this prevents a panic; status must be > 0
228 - rr.statusCode = http.StatusOK
225 + rr.WriteHeader(http.StatusOK)
226 + }
227 + if rr.stream {
228 + return nil
229 }
230 rr.ResponseWriterWrapper.WriteHeader(rr.statusCode)
231 _, err := io.Copy(rr.ResponseWriterWrapper, rr.buf)