From 44ad0cedafcd32d5edcf3c6ed62834641d10fa2f Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Wed, 21 Sep 2022 22:30:42 +0800 Subject: encode: don't WriteHeader unless called (#5060) --- modules/caddyhttp/encode/encode.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/caddyhttp/encode/encode.go b/modules/caddyhttp/encode/encode.go index f9e33ac..91e7060 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 } -- cgit v1.2.3