Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 11:45 UTC
encode: don't WriteHeader unless called (#5060)
WeidiDeng committed
Sep 21, 2022 at 22:30 UTC
44ad0cedafcd32d5edcf3c6ed62834641d10fa2f
1 file changed
+1
-4
modules/caddyhttp/encode/encode.go
+1
-4
@@ -241,8 +241,6 @@ func (rw *responseWriter) Write(p []byte) (int, error) {
241
if !rw.wroteHeader {
242
if rw.statusCode != 0 {
243
rw.HTTPInterfaces.WriteHeader(rw.statusCode)
244
- } else {
245
- rw.HTTPInterfaces.WriteHeader(http.StatusOK)
244
}
245
rw.wroteHeader = true
246
}
@@ -264,10 +262,9 @@ func (rw *responseWriter) Close() error {
262
rw.init()
263
}
264
265
+ // issue #5059, don't write status code if not set explicitly.
266
if rw.statusCode != 0 {
267
rw.HTTPInterfaces.WriteHeader(rw.statusCode)
269
- } else {
270
- rw.HTTPInterfaces.WriteHeader(http.StatusOK)
268
}
269
rw.wroteHeader = true
270
}