File tree Expand file tree Collapse file tree
src/main/java/com/terraformersmc/modmenu/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import java .net .http .HttpClient ;
1010import java .net .http .HttpRequest ;
1111import java .net .http .HttpResponse ;
12+ import java .time .Duration ;
1213
1314public class HttpUtil {
15+ private static final Duration TIMEOUT = Duration .ofSeconds (30 );
1416 private static final String USER_AGENT = buildUserAgent ();
1517 private static final HttpClient HTTP_CLIENT = HttpClient .newBuilder ()
1618 .executor (Util .nonCriticalIoPool ())
19+ .connectTimeout (TIMEOUT )
1720 .build ();
1821
1922 private HttpUtil () {
@@ -24,6 +27,7 @@ public static <T> HttpResponse<T> request(
2427 HttpResponse .BodyHandler <T > handler
2528 ) throws IOException , InterruptedException {
2629 builder .setHeader ("User-Agent" , USER_AGENT );
30+ builder .timeout (TIMEOUT );
2731 return HTTP_CLIENT .send (builder .build (), handler );
2832 }
2933
You can’t perform that action at this time.
0 commit comments