From b6bfd19cc24e7fdebb7dba1c941cdfe5d12d4ade Mon Sep 17 00:00:00 2001 From: yusing Date: Sun, 13 Jul 2025 15:42:39 +0800 Subject: [PATCH] fix(middleware): set Accept-Encoding to "" in modify_html middleware --- internal/net/gphttp/middleware/modify_html.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/net/gphttp/middleware/modify_html.go b/internal/net/gphttp/middleware/modify_html.go index a397949..2c7e31f 100644 --- a/internal/net/gphttp/middleware/modify_html.go +++ b/internal/net/gphttp/middleware/modify_html.go @@ -20,6 +20,11 @@ type modifyHTML struct { var ModifyHTML = NewMiddleware[modifyHTML]() +func (m *modifyHTML) before(w http.ResponseWriter, req *http.Request) bool { + req.Header.Set("Accept-Encoding", "") + return true +} + // modifyResponse implements ResponseModifier. func (m *modifyHTML) modifyResponse(resp *http.Response) error { // including text/html and application/xhtml+xml @@ -63,6 +68,7 @@ func (m *modifyHTML) modifyResponse(resp *http.Response) error { } resp.ContentLength = int64(len(h)) resp.Header.Set("Content-Length", strconv.Itoa(len(h))) + resp.Header.Set("Content-Type", "text/html; charset=utf-8") resp.Body = io.NopCloser(bytes.NewReader(h)) return nil }