mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-27 01:50:30 +08:00
忽略301, 302, 303, 307, 308响应中没有Location的错误提示
This commit is contained in:
@@ -282,16 +282,22 @@ func (this *HTTPRequest) doReverseProxy() {
|
||||
// 替换Location中的源站地址
|
||||
var locationHeader = resp.Header.Get("Location")
|
||||
if len(locationHeader) > 0 {
|
||||
locationURL, err := url.Parse(locationHeader)
|
||||
if err == nil && locationURL.Host != this.ReqHost && (locationURL.Host == originAddr || strings.HasPrefix(originAddr, locationURL.Host+":")) {
|
||||
locationURL.Host = this.ReqHost
|
||||
if this.IsHTTP {
|
||||
locationURL.Scheme = "http"
|
||||
} else if this.IsHTTPS {
|
||||
locationURL.Scheme = "https"
|
||||
}
|
||||
// 空Location处理
|
||||
if locationHeader == emptyHTTPLocation {
|
||||
resp.Header.Del("Location")
|
||||
} else {
|
||||
// 自动修正Location中的源站地址
|
||||
locationURL, err := url.Parse(locationHeader)
|
||||
if err == nil && locationURL.Host != this.ReqHost && (locationURL.Host == originAddr || strings.HasPrefix(originAddr, locationURL.Host+":")) {
|
||||
locationURL.Host = this.ReqHost
|
||||
if this.IsHTTP {
|
||||
locationURL.Scheme = "http"
|
||||
} else if this.IsHTTPS {
|
||||
locationURL.Scheme = "https"
|
||||
}
|
||||
|
||||
resp.Header.Set("Location", locationURL.String())
|
||||
resp.Header.Set("Location", locationURL.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user