diff options
Diffstat (limited to 'http-utils')
-rw-r--r-- | http-utils/src/main/java/ai/vespa/util/http/hc5/HttpToHttpsRoutePlanner.java | 9 |
1 files changed, 4 insertions, 5 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 8275098cb8d..0c140ce236e 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; @@ -15,19 +16,17 @@ import org.apache.hc.core5.http.protocol.HttpContext; */ class HttpToHttpsRoutePlanner implements HttpRoutePlanner { - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public HttpRoute determineRoute(HttpHost target, HttpContext context) { 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)); } } |