aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndreas Kohn <[email protected]>2024-06-07 15:25:36 +0200
committerGitHub <[email protected]>2024-06-07 07:25:36 -0600
commit9be4f194e036dddd4704a851fd15a9682d9e813d (patch)
tree23cf6980937adab8c0e532c39afb5c383aa22ff1
parenta10117f8bdbfd72fe585b7bb0c4b43ad8f6908bc (diff)
downloadcaddy-9be4f194e036dddd4704a851fd15a9682d9e813d.tar.gz
caddy-9be4f194e036dddd4704a851fd15a9682d9e813d.zip
caddyhttp: Write header if needed in responseRecorder.WriteResponse (#6380)
-rw-r--r--modules/caddyhttp/responsewriter.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/caddyhttp/responsewriter.go b/modules/caddyhttp/responsewriter.go
index d51d37cb2..808d2de3a 100644
--- a/modules/caddyhttp/responsewriter.go
+++ b/modules/caddyhttp/responsewriter.go
@@ -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)