aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/utils/Http.java
diff options
context:
space:
mode:
authorKevin <92656833+kevinthegreat1@users.noreply.github.com>2024-07-08 14:02:39 +0800
committerGitHub <noreply@github.com>2024-07-08 14:02:39 +0800
commit438ff23df1e01e2d95ea3fa8ba77ccb975ad96f3 (patch)
treed152d385f24f403ca873b8fb091b8e1c55e8dc96 /src/main/java/de/hysky/skyblocker/utils/Http.java
parentc1b5447162519e67f76a1ed7dd3a0a0121963ab9 (diff)
parentb6fec0afbe6b3555e8544ff6dd1792ea3ed21d03 (diff)
downloadSkyblocker-438ff23df1e01e2d95ea3fa8ba77ccb975ad96f3.tar.gz
Skyblocker-438ff23df1e01e2d95ea3fa8ba77ccb975ad96f3.tar.bz2
Skyblocker-438ff23df1e01e2d95ea3fa8ba77ccb975ad96f3.zip
Merge pull request #751 from Emirlol/more-efficient-mayor-check
Schedule mayor cache ticking to the next year rather than every 20 mins
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/Http.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/Http.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/Http.java b/src/main/java/de/hysky/skyblocker/utils/Http.java
index 1adf75d3..051bd52e 100644
--- a/src/main/java/de/hysky/skyblocker/utils/Http.java
+++ b/src/main/java/de/hysky/skyblocker/utils/Http.java
@@ -33,7 +33,7 @@ public class Http {
.followRedirects(Redirect.NORMAL)
.build();
- private static ApiResponse sendCacheableGetRequest(String url, @Nullable String token) throws IOException, InterruptedException {
+ public static ApiResponse sendCacheableGetRequest(String url, @Nullable String token) throws IOException, InterruptedException {
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.GET()
.header("Accept", "application/json")
@@ -66,9 +66,8 @@ public class Http {
.build();
HttpResponse<InputStream> response = HTTP_CLIENT.send(request, BodyHandlers.ofInputStream());
- InputStream decodedInputStream = getDecodedInputStream(response);
- return decodedInputStream;
+ return getDecodedInputStream(response);
}
public static String sendGetRequest(String url) throws IOException, InterruptedException {
@@ -125,16 +124,12 @@ public class Http {
String encoding = getContentEncoding(response.headers());
try {
- switch (encoding) {
- case "":
- return response.body();
- case "gzip":
- return new GZIPInputStream(response.body());
- case "deflate":
- return new InflaterInputStream(response.body());
- default:
- throw new UnsupportedOperationException("The server sent content in an unexpected encoding: " + encoding);
- }
+ return switch (encoding) {
+ case "" -> response.body();
+ case "gzip" -> new GZIPInputStream(response.body());
+ case "deflate" -> new InflaterInputStream(response.body());
+ default -> throw new UnsupportedOperationException("The server sent content in an unexpected encoding: " + encoding);
+ };
} catch (IOException e) {
throw new UncheckedIOException(e);
}