fix: detect HTML error bodies without text/html content type

This commit is contained in:
hkfires
2025-11-19 14:43:32 +08:00
parent 7a8e00fcea
commit 8a33f3ef69

View File

@@ -323,7 +323,14 @@ func formatAuthInfo(info upstreamRequestLog) string {
} }
func summarizeErrorBody(contentType string, body []byte) string { func summarizeErrorBody(contentType string, body []byte) string {
if strings.Contains(strings.ToLower(contentType), "text/html") { isHTML := strings.Contains(strings.ToLower(contentType), "text/html")
if !isHTML {
trimmed := bytes.TrimSpace(bytes.ToLower(body))
if bytes.HasPrefix(trimmed, []byte("<!doctype html")) || bytes.HasPrefix(trimmed, []byte("<html")) {
isHTML = true
}
}
if isHTML {
if title := extractHTMLTitle(body); title != "" { if title := extractHTMLTitle(body); title != "" {
return title return title
} }