aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/encode/encode.go
diff options
context:
space:
mode:
authorWeidiDeng <[email protected]>2022-09-21 22:30:42 +0800
committerGitHub <[email protected]>2022-09-21 08:30:42 -0600
commit44ad0cedafcd32d5edcf3c6ed62834641d10fa2f (patch)
tree24ba800eb005eeaf353656f38b6ff18b2c258969 /modules/caddyhttp/encode/encode.go
parentbeb7dcbf2aa0d523ad230d21187e923ecd676eba (diff)
downloadcaddy-44ad0cedafcd32d5edcf3c6ed62834641d10fa2f.tar.gz
caddy-44ad0cedafcd32d5edcf3c6ed62834641d10fa2f.zip
encode: don't WriteHeader unless called (#5060)
Diffstat (limited to 'modules/caddyhttp/encode/encode.go')
-rw-r--r--modules/caddyhttp/encode/encode.go5
1 files changed, 1 insertions, 4 deletions
diff --git a/modules/caddyhttp/encode/encode.go b/modules/caddyhttp/encode/encode.go
index f9e33ac91..91e7060a6 100644
--- a/modules/caddyhttp/encode/encode.go
+++ b/modules/caddyhttp/encode/encode.go
@@ -241,8 +241,6 @@ func (rw *responseWriter) Write(p []byte) (int, error) {
if !rw.wroteHeader {
if rw.statusCode != 0 {
rw.HTTPInterfaces.WriteHeader(rw.statusCode)
- } else {
- rw.HTTPInterfaces.WriteHeader(http.StatusOK)
}
rw.wroteHeader = true
}
@@ -264,10 +262,9 @@ func (rw *responseWriter) Close() error {
rw.init()
}
+ // issue #5059, don't write status code if not set explicitly.
if rw.statusCode != 0 {
rw.HTTPInterfaces.WriteHeader(rw.statusCode)
- } else {
- rw.HTTPInterfaces.WriteHeader(http.StatusOK)
}
rw.wroteHeader = true
}