From fa7519bdcd184ed4b7d74a9cc77131779ea09cc4 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Fri, 3 Apr 2020 23:16:14 +0200 Subject: [PATCH] MangaHub: fix 4.3 infinite loop --- src/be/nikiroo/fanfix/supported/MangaHub.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/be/nikiroo/fanfix/supported/MangaHub.java b/src/be/nikiroo/fanfix/supported/MangaHub.java index 437914a..99e8569 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; -- 2.27.0