fix(middleware): skip modification for HEAD requests in ModifyHTML middleware

This commit is contained in:
yusing
2025-12-04 17:27:26 +08:00
parent c098fef615
commit c1f9c2c957

View File

@@ -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