From c1f9c2c957187b37bb88ea41fa19e418655e6d32 Mon Sep 17 00:00:00 2001 From: yusing Date: Thu, 4 Dec 2025 17:27:26 +0800 Subject: [PATCH] fix(middleware): skip modification for HEAD requests in ModifyHTML middleware --- internal/net/gphttp/middleware/modify_html.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/net/gphttp/middleware/modify_html.go b/internal/net/gphttp/middleware/modify_html.go index c0c9d91d..3557e884 100644 --- a/internal/net/gphttp/middleware/modify_html.go +++ b/internal/net/gphttp/middleware/modify_html.go @@ -40,6 +40,10 @@ func (eofReader) Close() error { return nil } // modifyResponse implements ResponseModifier. func (m *modifyHTML) modifyResponse(resp *http.Response) error { + // Skip HEAD requests - no body to modify + if resp.Request.Method == http.MethodHead { + return nil + } // including text/html and application/xhtml+xml if !httputils.GetContentType(resp.Header).IsHTML() { return nil