From 2663fb318c242f1c328497012974d7cbc53a807f Mon Sep 17 00:00:00 2001 From: Redkale Date: Mon, 28 Nov 2022 13:33:20 +0800 Subject: [PATCH] =?UTF-8?q?Utility=E4=BC=98=E5=8C=96=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/redkale/util/Utility.java | 226 ++++++++++---------- 1 file changed, 113 insertions(+), 113 deletions(-) diff --git a/src/main/java/org/redkale/util/Utility.java b/src/main/java/org/redkale/util/Utility.java index 4c3181f4b..75d6a8938 100644 --- a/src/main/java/org/redkale/util/Utility.java +++ b/src/main/java/org/redkale/util/Utility.java @@ -3363,120 +3363,120 @@ public final class Utility { return remoteHttpContent("POST", url, 0, null, null).toString(StandardCharsets.UTF_8); } - public static String postHttpContent(String url, int timeout) throws IOException { - return remoteHttpContent("POST", url, timeout, null, null).toString(StandardCharsets.UTF_8); + public static String postHttpContent(String url, int timeoutMs) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, null, null).toString(StandardCharsets.UTF_8); } public static String postHttpContent(String url, String body) throws IOException { return remoteHttpContent("POST", url, 0, null, body).toString(StandardCharsets.UTF_8); } - public static String postHttpContent(String url, int timeout, String body) throws IOException { - return remoteHttpContent("POST", url, timeout, null, body).toString(StandardCharsets.UTF_8); + public static String postHttpContent(String url, int timeoutMs, String body) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, null, body).toString(StandardCharsets.UTF_8); } public static String postHttpContent(String url, Map headers, String body) throws IOException { return remoteHttpContent("POST", url, 0, headers, body).toString(StandardCharsets.UTF_8); } - public static String postHttpContent(String url, int timeout, Map headers, String body) throws IOException { - return remoteHttpContent("POST", url, timeout, headers, body).toString(StandardCharsets.UTF_8); + public static String postHttpContent(String url, int timeoutMs, Map headers, String body) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, headers, body).toString(StandardCharsets.UTF_8); } public static String postHttpContent(String url, Charset charset) throws IOException { return remoteHttpContent("POST", url, 0, null, null).toString(charset.name()); } - public static String postHttpContent(String url, int timeout, Charset charset) throws IOException { - return remoteHttpContent("POST", url, timeout, null, null).toString(charset.name()); + public static String postHttpContent(String url, int timeoutMs, Charset charset) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, null, null).toString(charset.name()); } public static String postHttpContent(String url, Charset charset, String body) throws IOException { return remoteHttpContent("POST", url, 0, null, body).toString(charset.name()); } - public static String postHttpContent(String url, int timeout, Charset charset, String body) throws IOException { - return remoteHttpContent("POST", url, timeout, null, body).toString(charset.name()); + public static String postHttpContent(String url, int timeoutMs, Charset charset, String body) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, null, body).toString(charset.name()); } public static String postHttpContent(String url, Charset charset, Map headers, String body) throws IOException { return remoteHttpContent("POST", url, 0, headers, body).toString(charset.name()); } - public static String postHttpContent(String url, int timeout, Charset charset, Map headers, String body) throws IOException { - return remoteHttpContent("POST", url, timeout, headers, body).toString(charset.name()); + public static String postHttpContent(String url, int timeoutMs, Charset charset, Map headers, String body) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, headers, body).toString(charset.name()); } public static byte[] postHttpBytesContent(String url) throws IOException { return remoteHttpContent("POST", url, 0, null, null).toByteArray(); } - public static byte[] postHttpBytesContent(String url, int timeout) throws IOException { - return remoteHttpContent("POST", url, timeout, null, null).toByteArray(); + public static byte[] postHttpBytesContent(String url, int timeoutMs) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, null, null).toByteArray(); } public static byte[] postHttpBytesContent(String url, Map headers, String body) throws IOException { return remoteHttpContent("POST", url, 0, headers, body).toByteArray(); } - public static byte[] postHttpBytesContent(String url, int timeout, Map headers, String body) throws IOException { - return remoteHttpContent("POST", url, timeout, headers, body).toByteArray(); + public static byte[] postHttpBytesContent(String url, int timeoutMs, Map headers, String body) throws IOException { + return remoteHttpContent("POST", url, timeoutMs, headers, body).toByteArray(); } public static String getHttpContent(String url) throws IOException { return remoteHttpContent("GET", url, 0, null, null).toString(StandardCharsets.UTF_8); } - public static String getHttpContent(String url, int timeout) throws IOException { - return remoteHttpContent("GET", url, timeout, null, null).toString(StandardCharsets.UTF_8); + public static String getHttpContent(String url, int timeoutMs) throws IOException { + return remoteHttpContent("GET", url, timeoutMs, null, null).toString(StandardCharsets.UTF_8); } public static String getHttpContent(String url, Map headers, String body) throws IOException { return remoteHttpContent("GET", url, 0, headers, body).toString(StandardCharsets.UTF_8); } - public static String getHttpContent(String url, int timeout, Map headers, String body) throws IOException { - return remoteHttpContent("GET", url, timeout, headers, body).toString(StandardCharsets.UTF_8); + public static String getHttpContent(String url, int timeoutMs, Map headers, String body) throws IOException { + return remoteHttpContent("GET", url, timeoutMs, headers, body).toString(StandardCharsets.UTF_8); } public static String getHttpContent(String url, Charset charset) throws IOException { return remoteHttpContent("GET", url, 0, null, null).toString(charset.name()); } - public static String getHttpContent(String url, int timeout, Charset charset) throws IOException { - return remoteHttpContent("GET", url, timeout, null, null).toString(charset.name()); + public static String getHttpContent(String url, int timeoutMs, Charset charset) throws IOException { + return remoteHttpContent("GET", url, timeoutMs, null, null).toString(charset.name()); } public static String getHttpContent(String url, Charset charset, Map headers, String body) throws IOException { return remoteHttpContent("GET", url, 0, headers, body).toString(charset.name()); } - public static String getHttpContent(String url, int timeout, Charset charset, Map headers, String body) throws IOException { - return remoteHttpContent("GET", url, timeout, headers, body).toString(charset.name()); + public static String getHttpContent(String url, int timeoutMs, Charset charset, Map headers, String body) throws IOException { + return remoteHttpContent("GET", url, timeoutMs, headers, body).toString(charset.name()); } public static byte[] getHttpBytesContent(String url) throws IOException { return remoteHttpContent("GET", url, 0, null, null).toByteArray(); } - public static byte[] getHttpBytesContent(String url, int timeout) throws IOException { - return remoteHttpContent("GET", url, timeout, null, null).toByteArray(); + public static byte[] getHttpBytesContent(String url, int timeoutMs) throws IOException { + return remoteHttpContent("GET", url, timeoutMs, null, null).toByteArray(); } public static byte[] getHttpBytesContent(String url, Map headers, String body) throws IOException { return remoteHttpContent("GET", url, 0, headers, body).toByteArray(); } - public static byte[] getHttpBytesContent(String url, int timeout, Map headers, String body) throws IOException { - return remoteHttpContent("GET", url, timeout, headers, body).toByteArray(); + public static byte[] getHttpBytesContent(String url, int timeoutMs, Map headers, String body) throws IOException { + return remoteHttpContent("GET", url, timeoutMs, headers, body).toByteArray(); } public static String remoteHttpContent(HttpClient client, String method, String url, Charset charset) throws IOException { return remoteHttpContentAsync(client, method, url, 0, null, null).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); } - public static String remoteHttpContent(HttpClient client, String method, String url, int timeout, Charset charset) throws IOException { - return remoteHttpContentAsync(client, method, url, timeout, null, null).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); + public static String remoteHttpContent(HttpClient client, String method, String url, int timeoutMs, Charset charset) throws IOException { + return remoteHttpContentAsync(client, method, url, timeoutMs, null, null).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); } public static String remoteHttpContent(HttpClient client, String method, String url, Charset charset, Map headers) throws IOException { @@ -3487,36 +3487,36 @@ public final class Utility { return remoteHttpContentAsync(client, method, url, 0, headers, body).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); } - public static String remoteHttpContent(HttpClient client, String method, String url, int timeout, Charset charset, Map headers) throws IOException { - return remoteHttpContentAsync(client, method, url, timeout, headers, null).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); + public static String remoteHttpContent(HttpClient client, String method, String url, int timeoutMs, Charset charset, Map headers) throws IOException { + return remoteHttpContentAsync(client, method, url, timeoutMs, headers, null).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); } - public static String remoteHttpContent(HttpClient client, String method, String url, int timeout, Charset charset, Map headers, String body) throws IOException { - return remoteHttpContentAsync(client, method, url, timeout, headers, body).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); + public static String remoteHttpContent(HttpClient client, String method, String url, int timeoutMs, Charset charset, Map headers, String body) throws IOException { + return remoteHttpContentAsync(client, method, url, timeoutMs, headers, body).thenApply(out -> out.toString(charset == null ? StandardCharsets.UTF_8 : charset)).join(); } public static byte[] remoteHttpBytesContent(HttpClient client, String method, String url, Charset charset, Map headers, String body) throws IOException { return remoteHttpContentAsync(client, method, url, 0, headers, body).thenApply(out -> out.toByteArray()).join(); } - public static byte[] remoteHttpBytesContent(HttpClient client, String method, String url, int timeout, Charset charset, Map headers) throws IOException { - return remoteHttpContentAsync(client, method, url, timeout, headers, null).thenApply(out -> out.toByteArray()).join(); + public static byte[] remoteHttpBytesContent(HttpClient client, String method, String url, int timeoutMs, Charset charset, Map headers) throws IOException { + return remoteHttpContentAsync(client, method, url, timeoutMs, headers, null).thenApply(out -> out.toByteArray()).join(); } - public static byte[] remoteHttpBytesContent(HttpClient client, String method, String url, int timeout, Charset charset, Map headers, String body) throws IOException { - return remoteHttpContentAsync(client, method, url, timeout, headers, body).thenApply(out -> out.toByteArray()).join(); + public static byte[] remoteHttpBytesContent(HttpClient client, String method, String url, int timeoutMs, Charset charset, Map headers, String body) throws IOException { + return remoteHttpContentAsync(client, method, url, timeoutMs, headers, body).thenApply(out -> out.toByteArray()).join(); } public static ByteArrayOutputStream remoteHttpContent(String method, String url, Map headers, String body) throws IOException { return remoteHttpContent(method, url, 0, headers, body); } - public static ByteArrayOutputStream remoteHttpContent(String method, String url, int timeout, Map headers, String body) throws IOException { - return remoteHttpContentAsync(method, url, timeout, headers, body).join(); + public static ByteArrayOutputStream remoteHttpContent(String method, String url, int timeoutMs, Map headers, String body) throws IOException { + return remoteHttpContentAsync(method, url, timeoutMs, headers, body).join(); } - public static ByteArrayOutputStream remoteHttpContent(HttpClient client, String method, String url, int timeout, Map headers, String body) throws IOException { - return remoteHttpContentAsync(client, method, url, timeout, headers, body).join(); + public static ByteArrayOutputStream remoteHttpContent(HttpClient client, String method, String url, int timeoutMs, Map headers, String body) throws IOException { + return remoteHttpContentAsync(client, method, url, timeoutMs, headers, body).join(); } public static CompletableFuture postHttpContentAsync(String url) { @@ -3527,12 +3527,12 @@ public final class Utility { return remoteHttpContentAsync("POST", url, 0, null, null, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout) { - return remoteHttpContentAsync("POST", url, timeout, null, null).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, null).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, null, null, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, null, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } public static CompletableFuture postHttpContentAsync(String url, String body) { @@ -3543,12 +3543,12 @@ public final class Utility { return remoteHttpContentAsync("POST", url, 0, null, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, String body) { - return remoteHttpContentAsync("POST", url, timeout, null, body).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, String body) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, body).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, String body, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, null, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, String body, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } public static CompletableFuture postHttpContentAsync(String url, Map headers, String body) { @@ -3559,12 +3559,12 @@ public final class Utility { return remoteHttpContentAsync("POST", url, 0, headers, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Map headers, String body) { - return remoteHttpContentAsync("POST", url, timeout, headers, body).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Map headers, String body) { + return remoteHttpContentAsync("POST", url, timeoutMs, headers, body).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, headers, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, headers, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } public static CompletableFuture postHttpContentAsync(String url, Charset charset) { @@ -3575,12 +3575,12 @@ public final class Utility { return remoteHttpContentAsync("POST", url, 0, null, null, respHeaders).thenApply(out -> out.toString(charset)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Charset charset) { - return remoteHttpContentAsync("POST", url, timeout, null, null).thenApply(out -> out.toString(charset)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Charset charset) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, null).thenApply(out -> out.toString(charset)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Charset charset, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, null, null, respHeaders).thenApply(out -> out.toString(charset)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Charset charset, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, null, respHeaders).thenApply(out -> out.toString(charset)); } public static CompletableFuture postHttpContentAsync(String url, Charset charset, String body) { @@ -3615,12 +3615,12 @@ public final class Utility { return remoteHttpContentAsync(client, "POST", url, 0, headers, body, respHeaders).thenApply(out -> out.toString(charset)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Charset charset, String body) { - return remoteHttpContentAsync("POST", url, timeout, null, body).thenApply(out -> out.toString(charset)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Charset charset, String body) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, body).thenApply(out -> out.toString(charset)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Charset charset, String body, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, null, body, respHeaders).thenApply(out -> out.toString(charset)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Charset charset, String body, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, body, respHeaders).thenApply(out -> out.toString(charset)); } public static CompletableFuture postHttpContentAsync(String url, Charset charset, Map headers, String body) { @@ -3631,12 +3631,12 @@ public final class Utility { return remoteHttpContentAsync("POST", url, 0, headers, body, respHeaders).thenApply(out -> out.toString(charset)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Charset charset, Map headers, String body) { - return remoteHttpContentAsync("POST", url, timeout, headers, body).thenApply(out -> out.toString(charset)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Charset charset, Map headers, String body) { + return remoteHttpContentAsync("POST", url, timeoutMs, headers, body).thenApply(out -> out.toString(charset)); } - public static CompletableFuture postHttpContentAsync(String url, int timeout, Charset charset, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, headers, body, respHeaders).thenApply(out -> out.toString(charset)); + public static CompletableFuture postHttpContentAsync(String url, int timeoutMs, Charset charset, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, headers, body, respHeaders).thenApply(out -> out.toString(charset)); } public static CompletableFuture postHttpBytesContentAsync(String url) { @@ -3647,12 +3647,12 @@ public final class Utility { return remoteHttpContentAsync("POST", url, 0, null, null, respHeaders).thenApply(out -> out.toByteArray()); } - public static CompletableFuture postHttpBytesContentAsync(String url, int timeout) { - return remoteHttpContentAsync("POST", url, timeout, null, null).thenApply(out -> out.toByteArray()); + public static CompletableFuture postHttpBytesContentAsync(String url, int timeoutMs) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, null).thenApply(out -> out.toByteArray()); } - public static CompletableFuture postHttpBytesContentAsync(String url, int timeout, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, null, null, respHeaders).thenApply(out -> out.toByteArray()); + public static CompletableFuture postHttpBytesContentAsync(String url, int timeoutMs, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, null, null, respHeaders).thenApply(out -> out.toByteArray()); } public static CompletableFuture postHttpBytesContentAsync(String url, Map headers, String body) { @@ -3663,12 +3663,12 @@ public final class Utility { return remoteHttpContentAsync("POST", url, 0, headers, body, respHeaders).thenApply(out -> out.toByteArray()); } - public static CompletableFuture postHttpBytesContentAsync(String url, int timeout, Map headers, String body) { - return remoteHttpContentAsync("POST", url, timeout, headers, body).thenApply(out -> out.toByteArray()); + public static CompletableFuture postHttpBytesContentAsync(String url, int timeoutMs, Map headers, String body) { + return remoteHttpContentAsync("POST", url, timeoutMs, headers, body).thenApply(out -> out.toByteArray()); } - public static CompletableFuture postHttpBytesContentAsync(String url, int timeout, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync("POST", url, timeout, headers, body, respHeaders).thenApply(out -> out.toByteArray()); + public static CompletableFuture postHttpBytesContentAsync(String url, int timeoutMs, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync("POST", url, timeoutMs, headers, body, respHeaders).thenApply(out -> out.toByteArray()); } public static CompletableFuture getHttpContentAsync(String url) { @@ -3679,12 +3679,12 @@ public final class Utility { return remoteHttpContentAsync("GET", url, 0, null, null, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout) { - return remoteHttpContentAsync("GET", url, timeout, null, null).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs) { + return remoteHttpContentAsync("GET", url, timeoutMs, null, null).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout, Map respHeaders) { - return remoteHttpContentAsync("GET", url, timeout, null, null, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs, Map respHeaders) { + return remoteHttpContentAsync("GET", url, timeoutMs, null, null, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } public static CompletableFuture getHttpContentAsync(String url, Map headers, String body) { @@ -3695,12 +3695,12 @@ public final class Utility { return remoteHttpContentAsync("GET", url, 0, headers, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout, Map headers, String body) { - return remoteHttpContentAsync("GET", url, timeout, headers, body).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs, Map headers, String body) { + return remoteHttpContentAsync("GET", url, timeoutMs, headers, body).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync("GET", url, timeout, headers, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync("GET", url, timeoutMs, headers, body, respHeaders).thenApply(out -> out.toString(StandardCharsets.UTF_8)); } public static CompletableFuture getHttpContentAsync(String url, Charset charset) { @@ -3711,12 +3711,12 @@ public final class Utility { return remoteHttpContentAsync("GET", url, 0, null, null, respHeaders).thenApply(out -> out.toString(charset)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout, Charset charset) { - return remoteHttpContentAsync("GET", url, timeout, null, null).thenApply(out -> out.toString(charset)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs, Charset charset) { + return remoteHttpContentAsync("GET", url, timeoutMs, null, null).thenApply(out -> out.toString(charset)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout, Charset charset, Map respHeaders) { - return remoteHttpContentAsync("GET", url, timeout, null, null, respHeaders).thenApply(out -> out.toString(charset)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs, Charset charset, Map respHeaders) { + return remoteHttpContentAsync("GET", url, timeoutMs, null, null, respHeaders).thenApply(out -> out.toString(charset)); } public static CompletableFuture getHttpContentAsync(String url, Charset charset, Map headers, String body) { @@ -3727,12 +3727,12 @@ public final class Utility { return remoteHttpContentAsync("GET", url, 0, headers, body, respHeaders).thenApply(out -> out.toString(charset)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout, Charset charset, Map headers, String body) { - return remoteHttpContentAsync("GET", url, timeout, headers, body).thenApply(out -> out.toString(charset)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs, Charset charset, Map headers, String body) { + return remoteHttpContentAsync("GET", url, timeoutMs, headers, body).thenApply(out -> out.toString(charset)); } - public static CompletableFuture getHttpContentAsync(String url, int timeout, Charset charset, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync("GET", url, timeout, headers, body, respHeaders).thenApply(out -> out.toString(charset)); + public static CompletableFuture getHttpContentAsync(String url, int timeoutMs, Charset charset, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync("GET", url, timeoutMs, headers, body, respHeaders).thenApply(out -> out.toString(charset)); } public static CompletableFuture getHttpContentAsync(java.net.http.HttpClient client, String url, String body, Map respHeaders) { @@ -3755,12 +3755,12 @@ public final class Utility { return remoteHttpContentAsync("GET", url, 0, null, null, respHeaders).thenApply(out -> out.toByteArray()); } - public static CompletableFuture getHttpBytesContentAsync(String url, int timeout) { - return remoteHttpContentAsync("GET", url, timeout, null, null).thenApply(out -> out.toByteArray()); + public static CompletableFuture getHttpBytesContentAsync(String url, int timeoutMs) { + return remoteHttpContentAsync("GET", url, timeoutMs, null, null).thenApply(out -> out.toByteArray()); } - public static CompletableFuture getHttpBytesContentAsync(String url, int timeout, Map respHeaders) { - return remoteHttpContentAsync("GET", url, timeout, null, null, respHeaders).thenApply(out -> out.toByteArray()); + public static CompletableFuture getHttpBytesContentAsync(String url, int timeoutMs, Map respHeaders) { + return remoteHttpContentAsync("GET", url, timeoutMs, null, null, respHeaders).thenApply(out -> out.toByteArray()); } public static CompletableFuture getHttpBytesContentAsync(String url, Map headers, String body) { @@ -3771,16 +3771,16 @@ public final class Utility { return remoteHttpContentAsync("GET", url, 0, headers, body, respHeaders).thenApply(out -> out.toByteArray()); } - public static CompletableFuture getHttpBytesContentAsync(String url, int timeout, Map headers, String body) { - return remoteHttpContentAsync("GET", url, timeout, headers, body).thenApply(out -> out.toByteArray()); + public static CompletableFuture getHttpBytesContentAsync(String url, int timeoutMs, Map headers, String body) { + return remoteHttpContentAsync("GET", url, timeoutMs, headers, body).thenApply(out -> out.toByteArray()); } - public static CompletableFuture getHttpBytesContentAsync(String url, int timeout, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync("GET", url, timeout, headers, body, respHeaders).thenApply(out -> out.toByteArray()); + public static CompletableFuture getHttpBytesContentAsync(String url, int timeoutMs, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync("GET", url, timeoutMs, headers, body, respHeaders).thenApply(out -> out.toByteArray()); } - public static CompletableFuture getHttpBytesContentAsync(java.net.http.HttpClient client, String url, int timeout, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync(client, "GET", url, timeout, headers, body, respHeaders).thenApply(out -> out.toByteArray()); + public static CompletableFuture getHttpBytesContentAsync(java.net.http.HttpClient client, String url, int timeoutMs, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync(client, "GET", url, timeoutMs, headers, body, respHeaders).thenApply(out -> out.toByteArray()); } public static CompletableFuture remoteHttpContentAsync(String method, String url, Map headers, String body) { @@ -3791,21 +3791,21 @@ public final class Utility { return remoteHttpContentAsync(method, url, 0, headers, body, respHeaders); } - public static CompletableFuture remoteHttpContentAsync(String method, String url, int timeout, Map headers, String body) { - return remoteHttpContentAsync(httpClient, method, url, timeout, headers, body); + public static CompletableFuture remoteHttpContentAsync(String method, String url, int timeoutMs, Map headers, String body) { + return remoteHttpContentAsync(httpClient, method, url, timeoutMs, headers, body); } - public static CompletableFuture remoteHttpContentAsync(String method, String url, int timeout, Map headers, String body, Map respHeaders) { - return remoteHttpContentAsync(httpClient, method, url, timeout, headers, body, respHeaders); + public static CompletableFuture remoteHttpContentAsync(String method, String url, int timeoutMs, Map headers, String body, Map respHeaders) { + return remoteHttpContentAsync(httpClient, method, url, timeoutMs, headers, body, respHeaders); } - public static CompletableFuture remoteHttpContentAsync(java.net.http.HttpClient client, String method, String url, int timeout, Map headers, String body) { - return remoteHttpContentAsync(client, method, url, timeout, headers, body, null); + public static CompletableFuture remoteHttpContentAsync(java.net.http.HttpClient client, String method, String url, int timeoutMs, Map headers, String body) { + return remoteHttpContentAsync(client, method, url, timeoutMs, headers, body, null); } - public static CompletableFuture remoteHttpContentAsync(java.net.http.HttpClient client, String method, String url, int timeout, Map headers, String body, Map respHeaders) { + public static CompletableFuture remoteHttpContentAsync(java.net.http.HttpClient client, String method, String url, int timeoutMs, Map headers, String body, Map respHeaders) { java.net.http.HttpRequest.Builder builder = java.net.http.HttpRequest.newBuilder().uri(URI.create(url)) - .timeout(Duration.ofMillis(timeout > 0 ? timeout : 6000)) + .timeout(Duration.ofMillis(timeoutMs > 0 ? timeoutMs : 6000)) .method(method, body == null ? java.net.http.HttpRequest.BodyPublishers.noBody() : java.net.http.HttpRequest.BodyPublishers.ofString(body)); if (headers != null) headers.forEach((n, v) -> builder.header(n, v)); java.net.http.HttpClient c = client == null ? httpClient : client; @@ -3823,7 +3823,7 @@ public final class Utility { if (rs == 301 || rs == 302) { Optional opt = resp.headers().firstValue("Location"); if (opt.isPresent()) { - return remoteHttpContentAsync(client, method, opt.get(), timeout, headers, body); + return remoteHttpContentAsync(client, method, opt.get(), timeoutMs, headers, body); } else { return CompletableFuture.failedFuture(new IOException(url + " httpcode = " + rs + ", but not found Localtion")); } @@ -3854,12 +3854,12 @@ public final class Utility { }); } // -// public static ByteArrayOutputStream remoteHttpContent(SSLContext ctx, String method, String url, int timeout, Map headers, String body) throws IOException { +// public static ByteArrayOutputStream remoteHttpContent(SSLContext ctx, String method, String url, int timeoutMs, Map headers, String body) throws IOException { // HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); // boolean opening = true; // try { -// conn.setConnectTimeout(timeout > 0 ? timeout : 3000); -// conn.setReadTimeout(timeout > 0 ? timeout : 3000); +// conn.setConnectTimeout(timeoutMs > 0 ? timeoutMs : 3000); +// conn.setReadTimeout(timeoutMs > 0 ? timeoutMs : 3000); // if (conn instanceof HttpsURLConnection) { // HttpsURLConnection httpsconn = ((HttpsURLConnection) conn); // httpsconn.setSSLSocketFactory((ctx == null ? DEFAULTSSL_CONTEXT : ctx).getSocketFactory()); @@ -3882,7 +3882,7 @@ public final class Utility { // String newurl = conn.getHeaderField("Location"); // conn.disconnect(); // opening = false; -// return remoteHttpContent(ctx, method, newurl, timeout, headers, body); +// return remoteHttpContent(ctx, method, newurl, timeoutMs, headers, body); // } // InputStream in = (rs < 400 || rs == 404) && rs != 405 ? conn.getInputStream() : conn.getErrorStream(); // if ("gzip".equalsIgnoreCase(conn.getContentEncoding())) in = new GZIPInputStream(in);