fix: cannot download library when .pack.xz responded not 404

This commit is contained in:
huanghongxun 2020-04-08 21:17:21 +08:00
parent 9372d818a5
commit b957ca1931

View File

@ -214,11 +214,11 @@ public final class NetworkUtils {
} }
public static boolean urlExists(URL url) throws IOException { public static boolean urlExists(URL url) throws IOException {
try (InputStream stream = url.openStream()) { HttpURLConnection con = createConnection(url);
return true; con = resolveConnection(con);
} catch (FileNotFoundException e) { int responseCode = con.getResponseCode();
return false; con.disconnect();
} return responseCode / 100 == 2;
} }
// ==== Shortcut methods for encoding/decoding URLs in UTF-8 ==== // ==== Shortcut methods for encoding/decoding URLs in UTF-8 ====