使 NetworkUtils.doGet 支持更多 URI scheme (#4768)
This commit is contained in:
@@ -144,8 +144,7 @@ public final class NetworkUtils {
|
|||||||
}
|
}
|
||||||
connection.setConnectTimeout(TIME_OUT);
|
connection.setConnectTimeout(TIME_OUT);
|
||||||
connection.setReadTimeout(TIME_OUT);
|
connection.setReadTimeout(TIME_OUT);
|
||||||
if (connection instanceof HttpURLConnection) {
|
if (connection instanceof HttpURLConnection httpConnection) {
|
||||||
var httpConnection = (HttpURLConnection) connection;
|
|
||||||
httpConnection.setRequestProperty("Accept-Language", Locale.getDefault().toLanguageTag());
|
httpConnection.setRequestProperty("Accept-Language", Locale.getDefault().toLanguageTag());
|
||||||
httpConnection.setInstanceFollowRedirects(false);
|
httpConnection.setInstanceFollowRedirects(false);
|
||||||
}
|
}
|
||||||
@@ -276,7 +275,11 @@ public final class NetworkUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String doGet(URI uri) throws IOException {
|
public static String doGet(URI uri) throws IOException {
|
||||||
return readFullyAsString(resolveConnection(createHttpConnection(uri)));
|
URLConnection connection = createConnection(uri);
|
||||||
|
if (connection instanceof HttpURLConnection httpURLConnection) {
|
||||||
|
connection = resolveConnection(httpURLConnection);
|
||||||
|
}
|
||||||
|
return readFullyAsString(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String doGet(List<URI> uris) throws IOException {
|
public static String doGet(List<URI> uris) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user