From 5052d20fbda33c89bb9112478852ff096f7603af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 13 Jan 2024 16:29:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E7=BC=96=E7=A0=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=A2=9E=E5=8A=A0=E2=80=9C=E5=BC=BA=E5=88=B6=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E2=80=9D=E9=80=89=E9=A1=B9=EF=BC=9B=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E7=BC=96=E7=A0=81=E5=A4=A7=E5=86=99=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_reverse_proxy.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/nodes/http_request_reverse_proxy.go b/internal/nodes/http_request_reverse_proxy.go index d7788e8..72ed02f 100644 --- a/internal/nodes/http_request_reverse_proxy.go +++ b/internal/nodes/http_request_reverse_proxy.go @@ -442,13 +442,23 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId } // 设置Charset - // TODO 这里应该可以设置文本类型的列表,以及是否强制覆盖所有文本类型的字符集 + // TODO 这里应该可以设置文本类型的列表 if this.web.Charset != nil && this.web.Charset.IsOn && len(this.web.Charset.Charset) > 0 { contentTypes, ok := resp.Header["Content-Type"] if ok && len(contentTypes) > 0 { var contentType = contentTypes[0] + if this.web.Charset.Force { + var semiIndex = strings.Index(contentType, ";") + if semiIndex > 0 { + contentType = contentType[:semiIndex] + } + } if _, found := textMimeMap[contentType]; found { - resp.Header["Content-Type"][0] = contentType + "; charset=" + this.web.Charset.Charset + var newCharset = this.web.Charset.Charset + if this.web.Charset.IsUpper { + newCharset = strings.ToUpper(newCharset) + } + resp.Header["Content-Type"][0] = contentType + "; charset=" + newCharset } } }