1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

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

This commit is contained in:
Andreas Kohn 2024-06-07 15:25:36 +02:00 committed by GitHub
parent a10117f8bd
commit 9be4f194e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -219,13 +219,13 @@ func (rr *responseRecorder) Buffered() bool {
}
func (rr *responseRecorder) WriteResponse() error {
if rr.stream {
return nil
}
if rr.statusCode == 0 {
// could happen if no handlers actually wrote anything,
// and this prevents a panic; status must be > 0
rr.statusCode = http.StatusOK
rr.WriteHeader(http.StatusOK)
}
if rr.stream {
return nil
}
rr.ResponseWriterWrapper.WriteHeader(rr.statusCode)
_, err := io.Copy(rr.ResponseWriterWrapper, rr.buf)