Skip to content

Commit

Permalink
[bugfix] fix wrong http user-agent content (#2996)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 authored Jan 19, 2025
1 parent 5441838 commit fd7e1b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,25 @@ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) thr
ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(1, threadFactory);
scheduledExecutor.scheduleWithFixedDelay(() -> {
connectionManager.closeExpiredConnections();
connectionManager.closeIdleConnections(100, TimeUnit.SECONDS);
connectionManager.closeIdleConnections(40, TimeUnit.SECONDS);
}, 40L, 40L, TimeUnit.SECONDS);

// shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(CommonHttpClient::close));

} catch (Exception ignored) {}
}

public static CloseableHttpClient getHttpClient() {
return httpClient;
}

public static void close() {
try {
httpClient.close();
} catch (Exception e) {
log.error("close http client error", e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface NetworkConstants {

String KEEP_ALIVE = "Keep-Alive";

String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36\")";
String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36";

String IPV6 = "ipv6";

Expand Down Expand Up @@ -59,14 +59,8 @@ interface HttpClientConstants {
int READ_TIME_OUT = 6 * 1000;
int WRITE_TIME_OUT = 6 * 1000;
int CONNECT_TIME_OUT = 6 * 1000;
int CHUNK_SIZE = 8196;
int MAX_IDLE_CONNECTIONS = 20;
int KEEP_ALIVE_TIMEOUT = 30 * 1000;
int HTTP_CLIENT_CONNECTION_MANAGER_MAX_PER_ROUTE = 20;
int HTTP_CLIENT_CONNECTION_MANAGER_MAX_TOTAL = 20;
int HTTPCLIENT_KEEP_ALIVE_DURATION = 30 * 1000;
int HTTP_CLIENT_CONNECTION_MANAGER_CLOSE_WAIT_TIME_MS = 1000;
int HTTP_CLIENT_CONNECTION_MANAGER_CLOSE_IDLE_TIME_S = 30;
}

}

0 comments on commit fd7e1b0

Please sign in to comment.