From c87f25d7bfa5f1f4fada75d38a6056ad20759cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Fri, 19 May 2023 19:52:04 +0800 Subject: [PATCH] =?UTF-8?q?HTTP=20Header=E4=B8=AD=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=9D=9E=E6=A0=87Header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/internal/nodes/http_request.go b/internal/nodes/http_request.go index 77e67cd..f1540ca 100644 --- a/internal/nodes/http_request.go +++ b/internal/nodes/http_request.go @@ -1650,6 +1650,20 @@ func (this *HTTPRequest) processRequestHeaders(reqHeader http.Header) { } } } + + // 非标Header + if len(this.web.RequestHeaderPolicy.NonStandardHeaders) > 0 { + for _, name := range this.web.RequestHeaderPolicy.NonStandardHeaders { + var canonicalKey = http.CanonicalHeaderKey(name) + if canonicalKey != name { + v, ok := reqHeader[canonicalKey] + if ok { + delete(reqHeader, canonicalKey) + reqHeader[name] = v + } + } + } + } } } @@ -1749,6 +1763,20 @@ func (this *HTTPRequest) processResponseHeaders(responseHeader http.Header, stat } } + // 非标Header + if len(this.web.ResponseHeaderPolicy.NonStandardHeaders) > 0 { + for _, name := range this.web.ResponseHeaderPolicy.NonStandardHeaders { + var canonicalKey = http.CanonicalHeaderKey(name) + if canonicalKey != name { + v, ok := responseHeader[canonicalKey] + if ok { + delete(responseHeader, canonicalKey) + responseHeader[name] = v + } + } + } + } + // CORS if this.web.ResponseHeaderPolicy.CORS != nil && this.web.ResponseHeaderPolicy.CORS.IsOn && (!this.web.ResponseHeaderPolicy.CORS.OptionsMethodOnly || this.RawReq.Method == http.MethodOptions) { var corsConfig = this.web.ResponseHeaderPolicy.CORS