Skip to content

Commit

Permalink
Throw if Date header does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed May 19, 2024
1 parent aeb22ae commit 56a10b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/net/raphimc/minecraftauth/util/TimeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static synchronized Duration getClientTimeOffset() {
final HttpResponse response = httpClient.execute(new GetRequest(OAuthEnvironment.LIVE.getBaseUrl()));

final Instant clientTime = Instant.now();
final Instant serverTime = response.getFirstHeader("Date").map(s -> DateTimeFormatter.RFC_1123_DATE_TIME.parse(s, Instant::from)).orElse(clientTime);
final Instant serverTime = response.getFirstHeader("Date").map(s -> DateTimeFormatter.RFC_1123_DATE_TIME.parse(s, Instant::from)).get();
CLIENT_TIME_OFFSET = Duration.between(clientTime, serverTime);

if (CLIENT_TIME_OFFSET.abs().compareTo(Duration.ofMinutes(2)) > 0) {
Expand Down

0 comments on commit 56a10b3

Please sign in to comment.