From: Niki Roo Date: Fri, 3 Apr 2020 21:16:14 +0000 (+0200) Subject: MangaHub: fix 4.3 infinite loop X-Git-Tag: fanfix-swing-0.0.1~12^2~6^2~7 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=fa7519bdcd184ed4b7d74a9cc77131779ea09cc4;p=fanfix-swing.git MangaHub: fix 4.3 infinite loop --- diff --git a/src/be/nikiroo/fanfix/supported/MangaHub.java b/src/be/nikiroo/fanfix/supported/MangaHub.java index 437914ac..99e85693 100644 --- a/src/be/nikiroo/fanfix/supported/MangaHub.java +++ b/src/be/nikiroo/fanfix/supported/MangaHub.java @@ -13,6 +13,7 @@ import java.util.Map.Entry; import org.jsoup.nodes.Element; import be.nikiroo.fanfix.Instance; +import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.utils.Image; import be.nikiroo.utils.Progress; @@ -186,14 +187,20 @@ class MangaHub extends BasicSupport { } // HTTP response code, or -1 if other error + // TODO: move that to Downloader? private int getHttpStatus(URL url) { try { - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); try { - connection.setRequestMethod("HEAD"); - return connection.getResponseCode(); + conn.setRequestMethod("HEAD"); + conn.setRequestProperty("User-Agent", Instance.getConfig().getString(Config.NETWORK_USER_AGENT)); + conn.setRequestProperty("Accept-Encoding", "gzip"); + conn.setRequestProperty("Accept", "*/*"); + conn.setRequestProperty("Charset", "utf-8"); + + return conn.getResponseCode(); } finally { - connection.disconnect(); + conn.disconnect(); } } catch (Exception e) { return -1;