mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Change name from sourceHost to sourceRequestHost.
This commit is contained in:
parent
3102f37e8a
commit
eff8136442
@ -131,23 +131,23 @@ func (rt *Transport) WrappedRoundTripper() http.RoundTripper {
|
|||||||
|
|
||||||
// rewriteURL rewrites a single URL to go through the proxy, if the URL refers
|
// rewriteURL rewrites a single URL to go through the proxy, if the URL refers
|
||||||
// to the same host as sourceURL, which is the page on which the target URL
|
// to the same host as sourceURL, which is the page on which the target URL
|
||||||
// occurred, or if the URL matches the sourceHost. If any error occurs (e.g.
|
// occurred, or if the URL matches the sourceRequestHost. If any error occurs (e.g.
|
||||||
// parsing), it returns targetURL.
|
// parsing), it returns targetURL.
|
||||||
func (t *Transport) rewriteURL(targetURL string, sourceURL *url.URL, sourceHost string) string {
|
func (t *Transport) rewriteURL(targetURL string, sourceURL *url.URL, sourceRequestHost string) string {
|
||||||
url, err := url.Parse(targetURL)
|
url, err := url.Parse(targetURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return targetURL
|
return targetURL
|
||||||
}
|
}
|
||||||
|
|
||||||
isDifferentHost := url.Host != "" && url.Host != sourceURL.Host && url.Host != sourceHost
|
isDifferentHost := url.Host != "" && url.Host != sourceURL.Host && url.Host != sourceRequestHost
|
||||||
isRelative := !strings.HasPrefix(url.Path, "/")
|
isRelative := !strings.HasPrefix(url.Path, "/")
|
||||||
if isDifferentHost || isRelative {
|
if isDifferentHost || isRelative {
|
||||||
return targetURL
|
return targetURL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not rewrite scheme and host if the Transport has empty scheme and host
|
// Do not rewrite scheme and host if the Transport has empty scheme and host
|
||||||
// when targetURL already contains the sourceHost
|
// when targetURL already contains the sourceRequestHost
|
||||||
if !(url.Host == sourceHost && t.Scheme == "" && t.Host == "") {
|
if !(url.Host == sourceRequestHost && t.Scheme == "" && t.Host == "") {
|
||||||
url.Scheme = t.Scheme
|
url.Scheme = t.Scheme
|
||||||
url.Host = t.Host
|
url.Host = t.Host
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user