Skip to content

Commit

Permalink
caddyhttp: Write header if needed in responseRecorder.WriteResponse (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ankon authored Jun 7, 2024
1 parent a10117f commit 9be4f19
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/caddyhttp/responsewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9be4f19

Please sign in to comment.