From ac55e336fe38a337672011beebcf88be728b5c4e Mon Sep 17 00:00:00 2001 From: iroqueta Date: Wed, 29 Apr 2026 18:18:43 -0300 Subject: [PATCH] HttpClient: omit default port 80 when rebuilding HTTP URLs When the original URL had no explicit port, HttpClientJavaLib was re-assembling it as http://host:80/path, sending Host: host:80 in the request. Some servers (e.g. IIS) copy the request authority verbatim into the Location header of a redirect, producing broken redirects to https://host:80/... that fail TLS handshake. Aligns the http branch with the https branch (which already omitted the default 443) so the port is only appended when it differs from the scheme default. --- java/src/main/java/com/genexus/internet/HttpClientJavaLib.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java b/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java index 2573a2b6a..e29a17a03 100644 --- a/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java +++ b/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java @@ -543,7 +543,7 @@ public void execute(String method, String url) { if (getSecure() == 1) // Se completa con esquema y host url = url.startsWith("https://") ? url : "https://" + getHost()+ (getPort() != 443?":"+getPort():"")+ url; // La lib de HttpClient agrega el port else - url = url.startsWith("http://") ? url : "http://" + getHost() + ":" + (getPort() == -1? "80" :getPort()) + url; + url = url.startsWith("http://") ? url : "http://" + getHost() + (getPort() != 80?":"+getPort(): "") + url; try (CloseableHttpClient httpClient = this.httpClientBuilder.build()) { if (method.equalsIgnoreCase("GET")) {