forked from MinecraftUtilities/Backend
only fetch the head on the endpoint status check
This commit is contained in:
parent
77bd9a7c7e
commit
55c2c95269
@ -60,4 +60,18 @@ public class WebRequest {
|
|||||||
.onStatus(HttpStatusCode::isError, (request, response) -> {}) // Don't throw exceptions on error
|
.onStatus(HttpStatusCode::isError, (request, response) -> {}) // Don't throw exceptions on error
|
||||||
.toEntity(clazz);
|
.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) {
|
for (EndpointStatus endpoint : MOJANG_ENDPOINTS) {
|
||||||
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
|
||||||
boolean online = false;
|
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())) {
|
if (endpoint.getAllowedStatuses().contains(response.getStatusCode())) {
|
||||||
online = true;
|
online = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user