only fetch the head on the endpoint status check
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m44s

This commit is contained in:
Lee 2024-04-13 16:30:22 +01:00
parent 77bd9a7c7e
commit 55c2c95269
2 changed files with 15 additions and 1 deletions

@ -60,4 +60,18 @@ public class WebRequest {
.onStatus(HttpStatusCode::isError, (request, response) -> {}) // Don't throw exceptions on error
.toEntity(clazz);
}
/**
* Gets a response from the given URL.
*
* @param url the url
* @return the response
*/
public static ResponseEntity<?> head(String url, Class<?> clazz) {
return CLIENT.head()
.uri(url)
.retrieve()
.onStatus(HttpStatusCode::isError, (request, response) -> {}) // Don't throw exceptions on error
.toEntity(clazz);
}
}

@ -199,7 +199,7 @@ public class MojangService {
for (EndpointStatus endpoint : MOJANG_ENDPOINTS) {
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
boolean online = false;
ResponseEntity<?> response = WebRequest.get(endpoint.getEndpoint(), String.class);
ResponseEntity<?> response = WebRequest.head(endpoint.getEndpoint(), String.class);
if (endpoint.getAllowedStatuses().contains(response.getStatusCode())) {
online = true;
}