mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] UserAgent в ListDownloader.
This commit is contained in:
parent
3d7c2f31ef
commit
cb91f83ec2
2 changed files with 3 additions and 2 deletions
|
@ -62,7 +62,7 @@ public DownloadTask(String apply, long size) {
|
|||
}
|
||||
|
||||
public void download(String base, List<DownloadTask> applies, Path dstDirFile, DownloadCallback callback, DownloadTotalCallback totalCallback) throws IOException, URISyntaxException {
|
||||
try (CloseableHttpClient httpclient = HttpClients.custom()
|
||||
try (CloseableHttpClient httpclient = HttpClients.custom().setUserAgent(IOHelper.USER_AGENT)
|
||||
.setRedirectStrategy(new LaxRedirectStrategy())
|
||||
.build()) {
|
||||
applies.sort((a,b) -> Long.compare(a.size, b.size));
|
||||
|
|
|
@ -168,6 +168,7 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce
|
|||
private static final Pattern CROSS_SEPARATOR_PATTERN = Pattern.compile(CROSS_SEPARATOR, Pattern.LITERAL);
|
||||
|
||||
private static final Pattern PLATFORM_SEPARATOR_PATTERN = Pattern.compile(PLATFORM_SEPARATOR, Pattern.LITERAL);
|
||||
public static final String USER_AGENT = System.getProperty("launcher.userAgentDefault", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
|
||||
|
||||
@LauncherAPI
|
||||
public static void close(AutoCloseable closeable) {
|
||||
|
@ -346,7 +347,7 @@ public static URLConnection newConnection(URL url) throws IOException {
|
|||
if (connection instanceof HttpURLConnection) {
|
||||
connection.setReadTimeout(HTTP_TIMEOUT);
|
||||
connection.setConnectTimeout(HTTP_TIMEOUT);
|
||||
connection.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // Fix for stupid servers
|
||||
connection.addRequestProperty("User-Agent", USER_AGENT); // Fix for stupid servers
|
||||
} else
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
|
|
Loading…
Reference in a new issue