aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--modules/caddyhttp/encode/encode.go21
1 files changed, 6 insertions, 15 deletions
diff --git a/modules/caddyhttp/encode/encode.go b/modules/caddyhttp/encode/encode.go
index bd3d84bc8..91f25294f 100644
--- a/modules/caddyhttp/encode/encode.go
+++ b/modules/caddyhttp/encode/encode.go
@@ -20,11 +20,9 @@
package encode
import (
- "bufio"
"fmt"
"io"
"math"
- "net"
"net/http"
"sort"
"strconv"
@@ -221,6 +219,12 @@ type responseWriter struct {
// to actually write the header.
func (rw *responseWriter) WriteHeader(status int) {
rw.statusCode = status
+
+ // write status immediately when status code is informational
+ // see: https://caddy.community/t/disappear-103-early-hints-response-with-encode-enable-caddy-v2-7-6/23081/5
+ if 100 <= status && status <= 199 {
+ rw.ResponseWriter.WriteHeader(status)
+ }
}
// Match determines, if encoding should be done based on the ResponseMatcher.
@@ -242,19 +246,6 @@ func (rw *responseWriter) Flush() {
http.NewResponseController(rw.ResponseWriter).Flush()
}
-// Hijack implements http.Hijacker. It will flush status code if set. We don't track actual hijacked
-// status assuming http middlewares will track its status.
-func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
- if !rw.wroteHeader {
- if rw.statusCode != 0 {
- rw.ResponseWriter.WriteHeader(rw.statusCode)
- }
- rw.wroteHeader = true
- }
- //nolint:bodyclose
- return http.NewResponseController(rw.ResponseWriter).Hijack()
-}
-
// Write writes to the response. If the response qualifies,
// it is encoded using the encoder, which is initialized
// if not done so already.