From d40bc4e72b30806c13bdfbadde4296b735fb5e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 20 Feb 2022 09:17:50 +0800 Subject: [PATCH] =?UTF-8?q?URL=E8=B7=B3=E8=BD=AC=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=98=AF=E5=90=A6=E4=BF=9D=E7=95=99=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_host_redirect.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/nodes/http_request_host_redirect.go b/internal/nodes/http_request_host_redirect.go index 39e9d7a..8cec3e9 100644 --- a/internal/nodes/http_request_host_redirect.go +++ b/internal/nodes/http_request_host_redirect.go @@ -73,6 +73,13 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { return false } + if u.KeepArgs { + var qIndex = strings.Index(this.uri, "?") + if qIndex >= 0 { + afterURL += this.uri[qIndex:] + } + } + if u.Status <= 0 { this.processResponseHeaders(http.StatusTemporaryRedirect) http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect) @@ -88,12 +95,20 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { return false } + var afterURL = u.AfterURL + if u.KeepArgs { + var qIndex = strings.Index(this.uri, "?") + if qIndex >= 0 { + afterURL += this.uri[qIndex:] + } + } + if u.Status <= 0 { this.processResponseHeaders(http.StatusTemporaryRedirect) - http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, http.StatusTemporaryRedirect) + http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect) } else { this.processResponseHeaders(u.Status) - http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, u.Status) + http.Redirect(this.RawWriter, this.RawReq, afterURL, u.Status) } return true }