[bugfix] fix wrong http user-agent content (#2996)

This commit is contained in:
tomsun28
2025-01-20 01:16:50 +08:00
committed by GitHub
parent 5441838888
commit fd7e1b0e05
2 changed files with 15 additions and 8 deletions
@@ -144,12 +144,25 @@ public class CommonHttpClient {
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);
}
}
}
@@ -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";
@@ -59,14 +59,8 @@ public interface NetworkConstants {
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;
}
}