diff options
author | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2023-01-26 12:53:19 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2023-01-26 12:53:19 +0100 |
commit | 034b8864be37add1c0822d3b56f252036dd88bc7 (patch) | |
tree | 0bf195de62ff2dff9bb4d1f810ea694b4a8fc694 /http-utils | |
parent | e172daaaa5513696889766daa7c3547b77b47d42 (diff) |
Resolve implicit port from original URI
Diffstat (limited to 'http-utils')
-rw-r--r-- | http-utils/src/main/java/ai/vespa/util/http/hc5/HttpToHttpsRoutePlanner.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/http-utils/src/main/java/ai/vespa/util/http/hc5/HttpToHttpsRoutePlanner.java b/http-utils/src/main/java/ai/vespa/util/http/hc5/HttpToHttpsRoutePlanner.java index 0a22437f5fc..cce73cf3b05 100644 --- a/http-utils/src/main/java/ai/vespa/util/http/hc5/HttpToHttpsRoutePlanner.java +++ b/http-utils/src/main/java/ai/vespa/util/http/hc5/HttpToHttpsRoutePlanner.java @@ -2,6 +2,7 @@ package ai.vespa.util.http.hc5; import org.apache.hc.client5.http.HttpRoute; +import org.apache.hc.client5.http.impl.DefaultSchemePortResolver; import org.apache.hc.client5.http.protocol.HttpClientContext; import org.apache.hc.client5.http.routing.HttpRoutePlanner; import org.apache.hc.core5.http.HttpHost; @@ -20,13 +21,11 @@ class HttpToHttpsRoutePlanner implements HttpRoutePlanner { if ( ! target.getSchemeName().equals("http") && ! target.getSchemeName().equals("https")) throw new IllegalArgumentException("Scheme must be 'http' or 'https' when using HttpToHttpsRoutePlanner, was '" + target.getSchemeName() + "'"); - if (target.getPort() == -1) - throw new IllegalArgumentException("Port must be set when using HttpToHttpsRoutePlanner"); - if (HttpClientContext.adapt(context).getRequestConfig().getProxy() != null) throw new IllegalArgumentException("Proxies are not supported with HttpToHttpsRoutePlanner"); - return new HttpRoute(new HttpHost("https", target.getAddress(), target.getHostName(), target.getPort())); + int port = DefaultSchemePortResolver.INSTANCE.resolve(target); + return new HttpRoute(new HttpHost("https", target.getAddress(), target.getHostName(), port)); } } |