Skip to content

Commit 9be4f19

Browse files
authored
caddyhttp: Write header if needed in responseRecorder.WriteResponse (#6380)
1 parent a10117f commit 9be4f19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/caddyhttp/responsewriter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ func (rr *responseRecorder) Buffered() bool {
219219
}
220220

221221
func (rr *responseRecorder) WriteResponse() error {
222-
if rr.stream {
223-
return nil
224-
}
225222
if rr.statusCode == 0 {
226223
// could happen if no handlers actually wrote anything,
227224
// 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
229229
}
230230
rr.ResponseWriterWrapper.WriteHeader(rr.statusCode)
231231
_, err := io.Copy(rr.ResponseWriterWrapper, rr.buf)

0 commit comments

Comments
 (0)