Skip to content

Commit 6606f03

Browse files
Add the option to tiemout per url and not per ip
1 parent 7df77fc commit 6606f03

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

java/src/main/java/com/genexus/internet/HttpClientJavaLib.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.http.conn.ssl.NoopHostnameVerifier;
2323
import org.apache.http.entity.ContentType;
2424
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
25+
import org.apache.http.impl.conn.SystemDefaultDnsResolver;
2526
import org.apache.http.protocol.HttpContext;
2627
import org.apache.http.auth.AuthSchemeProvider;
2728
import org.apache.http.auth.AuthScope;
@@ -68,6 +69,19 @@ public HttpClientJavaLib() {
6869
getPoolInstance();
6970
ConnectionKeepAliveStrategy myStrategy = generateKeepAliveStrategy();
7071
httpClientBuilder = HttpClients.custom().setConnectionManager(connManager).setConnectionManagerShared(true).setKeepAliveStrategy(myStrategy);
72+
String gxDns = System.getenv("GX_USE_FIRST_IP_DNS");
73+
if (gxDns == null || gxDns.trim().isEmpty()) {
74+
gxDns = System.getProperty("GX_USE_FIRST_IP_DNS");
75+
}
76+
if (gxDns != null && gxDns.trim().equalsIgnoreCase("true")) {
77+
httpClientBuilder.setDnsResolver(new SystemDefaultDnsResolver() {
78+
@Override
79+
public InetAddress[] resolve(String host) throws UnknownHostException {
80+
InetAddress[] all = super.resolve(host);
81+
return new InetAddress[] { all[0] };
82+
}
83+
});
84+
}
7185
cookies = new BasicCookieStore();
7286
streamsToClose = new Vector<>();
7387
}

0 commit comments

Comments
 (0)