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 3232import java .io .IOException ;
3333import java .io .InputStream ;
3434import java .io .InputStreamReader ;
35- import java .net .URL ;
35+ import java .net .URI ;
36+ import java .net .http .HttpClient ;
37+ import java .net .http .HttpRequest ;
38+ import java .net .http .HttpResponse ;
3639import java .nio .charset .StandardCharsets ;
37- import java .util .regex .Pattern ;
3840
3941/**
4042 * Helper methods for the Fabric and Quilt mod loader.
@@ -56,9 +58,14 @@ public static InputStreamReader getReader(final String urlString) {
5658 @ Nullable
5759 public static InputStream getStream (final String urlString ) {
5860 try {
59- final var url = new URL (urlString );
60- return url .openStream ();
61- } catch (IOException ex ) {
61+ HttpClient client = HttpClient .newHttpClient ();
62+ HttpRequest request = HttpRequest .newBuilder ()
63+ .uri (URI .create (urlString ))
64+ .build ();
65+
66+ HttpResponse <InputStream > response = client .send (request , HttpResponse .BodyHandlers .ofInputStream ());
67+ return response .body ();
68+ } catch (IOException | InterruptedException ex ) {
6269 TheCommander .LOGGER .error ("Failed to open input stream" , ex );
6370 return null ;
6471 }
You can’t perform that action at this time.
0 commit comments