From fe400464c2640ff9422ae2581469d06a9a7c9e5c Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 7 May 2020 11:25:13 +0200 Subject: [PATCH] Downloader: allow NULL useragent --- src/be/nikiroo/utils/Downloader.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/be/nikiroo/utils/Downloader.java b/src/be/nikiroo/utils/Downloader.java index 04879332..4191d0ae 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) */ @@ -433,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"); -- 2.27.0