From 2903241fe145137f6c1c925ed508c5673228a8d7 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Fri, 27 Oct 2023 23:53:11 -0400 Subject: Museum Item Cache --- src/main/java/de/hysky/skyblocker/utils/Http.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/utils/Http.java') diff --git a/src/main/java/de/hysky/skyblocker/utils/Http.java b/src/main/java/de/hysky/skyblocker/utils/Http.java index 94506b05..7e3a7a27 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Http.java +++ b/src/main/java/de/hysky/skyblocker/utils/Http.java @@ -51,7 +51,7 @@ public class Http { InputStream decodedInputStream = getDecodedInputStream(response); String body = new String(decodedInputStream.readAllBytes()); - return new ApiResponse(body, getCacheStatus(response.headers())); + return new ApiResponse(body, response.statusCode(), getCacheStatus(response.headers())); } public static HttpHeaders sendHeadRequest(String url) throws IOException, InterruptedException { @@ -120,7 +120,11 @@ public class Http { } //TODO If ever needed, we could just replace cache status with the response headers and go from there - public record ApiResponse(String content, String cacheStatus) { + public record ApiResponse(String content, int statusCode, String cacheStatus) { + + public boolean ok() { + return statusCode == 200; + } public boolean cached() { return cacheStatus.equals("HIT"); -- cgit