X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FDownloader.java;h=4191d0aea0da85511e2741c50c2a6c83806f612f;hp=c9a319aa0eb725159287562ae76718fc531c8097;hb=HEAD;hpb=47c88873d2d13652786751464abbeace5899ec1c diff --git a/src/be/nikiroo/utils/Downloader.java b/src/be/nikiroo/utils/Downloader.java index c9a319a..4191d0a 100644 --- a/src/be/nikiroo/utils/Downloader.java +++ b/src/be/nikiroo/utils/Downloader.java @@ -39,7 +39,7 @@ public class Downloader { * the User-Agent to use to download the resources -- note that * some websites require one, some actively blacklist real UAs * like the one from wget, some whitelist a couple of browsers - * only (!) + * only (!) -- can be NULL */ public Downloader(String UA) { this(UA, null); @@ -52,7 +52,7 @@ public class Downloader { * the User-Agent to use to download the resources -- note that * some websites require one, some actively blacklist real UAs * like the one from wget, some whitelist a couple of browsers - * only (!) + * only (!) -- can be NULL * @param cache * the {@link Cache} to use for all access (can be NULL) */ @@ -281,7 +281,9 @@ public class Downloader { } } - if (offline) { + String protocol = originalUrl == null ? null : originalUrl + .getProtocol(); + if (isOffline() && !"file".equalsIgnoreCase(protocol)) { tracer.error("Downloader OFFLINE, cannot proceed to URL: " + url); throw new IOException("Downloader is currently OFFLINE, cannot download: " + url); } @@ -431,7 +433,9 @@ public class Downloader { conn.setRequestProperty("Cookie", cookies); } - conn.setRequestProperty("User-Agent", UA); + if (UA != null) { + conn.setRequestProperty("User-Agent", UA); + } conn.setRequestProperty("Accept-Encoding", "gzip"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Charset", "utf-8");