File tree Expand file tree Collapse file tree
src/commander/java/com/mcmoddev/mmdbot/commander/updatenotifiers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040import java .time .Duration ;
4141
4242public class SharedVersionHelpers {
43-
43+ private static final HttpClient client = HttpClient .newBuilder ()
44+ .connectTimeout (Duration .ofSeconds (10L ))
45+ .followRedirects (HttpClient .Redirect .NORMAL )
46+ .build ();
4447
4548 public static InputStreamReader getReader (final String urlString ) {
4649 final InputStream stream = getStream (urlString );
@@ -54,12 +57,10 @@ public static InputStreamReader getReader(final String urlString) {
5457 @ Nullable
5558 public static InputStream getStream (final String urlString ) {
5659 try {
57- HttpClient client = HttpClient .newBuilder ()
58- .connectTimeout (Duration .ofSeconds (5L ))
59- .followRedirects (HttpClient .Redirect .NORMAL )
60- .build ();
6160 HttpRequest request = HttpRequest .newBuilder ()
6261 .uri (URI .create (urlString ))
62+ .header ("User-Agent" , "MMDBot" )
63+ .timeout (Duration .ofSeconds (30L ))
6364 .build ();
6465
6566 HttpResponse <InputStream > response = client .send (request , HttpResponse .BodyHandlers .ofInputStream ());
You can’t perform that action at this time.
0 commit comments