diff --git a/internal/nodes/http_request_host_redirect.go b/internal/nodes/http_request_host_redirect.go index 2103ae2..0772c5f 100644 --- a/internal/nodes/http_request_host_redirect.go +++ b/internal/nodes/http_request_host_redirect.go @@ -55,7 +55,7 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { } this.ProcessResponseHeaders(this.writer.Header(), status) - http.Redirect(this.RawWriter, this.RawReq, afterURL, status) + httpRedirect(this.writer, this.RawReq, afterURL, status) return true } } else if u.MatchRegexp { // 正则匹配 @@ -97,7 +97,7 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { } this.ProcessResponseHeaders(this.writer.Header(), status) - http.Redirect(this.RawWriter, this.RawReq, afterURL, status) + httpRedirect(this.writer, this.RawReq, afterURL, status) return true } else { // 精准匹配 if fullURL == u.RealBeforeURL() { @@ -120,7 +120,7 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { } this.ProcessResponseHeaders(this.writer.Header(), status) - http.Redirect(this.RawWriter, this.RawReq, afterURL, status) + httpRedirect(this.writer, this.RawReq, afterURL, status) return true } } @@ -163,7 +163,7 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { afterURL += this.uri[qIndex:] } - http.Redirect(this.RawWriter, this.RawReq, afterURL, status) + httpRedirect(this.writer, this.RawReq, afterURL, status) return true } } else if u.Type == serverconfigs.HTTPHostRedirectTypePort { @@ -212,7 +212,7 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { } this.ProcessResponseHeaders(this.writer.Header(), status) - http.Redirect(this.RawWriter, this.RawReq, afterURL, status) + httpRedirect(this.writer, this.RawReq, afterURL, status) return true } } diff --git a/internal/nodes/http_request_redirect_https.go b/internal/nodes/http_request_redirect_https.go index fc9e327..b7f6015 100644 --- a/internal/nodes/http_request_redirect_https.go +++ b/internal/nodes/http_request_redirect_https.go @@ -43,7 +43,7 @@ func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs. var newURL = "https://" + host + this.RawReq.RequestURI this.ProcessResponseHeaders(this.writer.Header(), statusCode) - http.Redirect(this.writer, this.RawReq, newURL, statusCode) + httpRedirect(this.writer, this.RawReq, newURL, statusCode) return true } diff --git a/internal/nodes/http_request_rewrite.go b/internal/nodes/http_request_rewrite.go index 49b9d40..5b3d63d 100644 --- a/internal/nodes/http_request_rewrite.go +++ b/internal/nodes/http_request_rewrite.go @@ -31,10 +31,10 @@ func (this *HTTPRequest) doRewrite() (shouldShop bool) { if this.rewriteRule.Mode == serverconfigs.HTTPRewriteModeRedirect { if this.rewriteRule.RedirectStatus > 0 { this.ProcessResponseHeaders(this.writer.Header(), this.rewriteRule.RedirectStatus) - http.Redirect(this.writer, this.RawReq, this.rewriteReplace, this.rewriteRule.RedirectStatus) + httpRedirect(this.writer, this.RawReq, this.rewriteReplace, this.rewriteRule.RedirectStatus) } else { this.ProcessResponseHeaders(this.writer.Header(), http.StatusTemporaryRedirect) - http.Redirect(this.writer, this.RawReq, this.rewriteReplace, http.StatusTemporaryRedirect) + httpRedirect(this.writer, this.RawReq, this.rewriteReplace, http.StatusTemporaryRedirect) } return true } diff --git a/internal/nodes/http_writer.go b/internal/nodes/http_writer.go index 334259d..0ccd363 100644 --- a/internal/nodes/http_writer.go +++ b/internal/nodes/http_writer.go @@ -908,7 +908,7 @@ func (this *HTTPWriter) SendResp(resp *http.Response) (int64, error) { // Redirect 跳转 func (this *HTTPWriter) Redirect(status int, url string) { - http.Redirect(this.rawWriter, this.req.RawReq, url, status) + httpRedirect(this, this.req.RawReq, url, status) this.isFinished = true }