From e4951a0623d3a344802b5d8d12d27f2365db441d Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 17 Mar 2022 16:19:06 +0100 Subject: [PATCH] Refactor code handling http headers in downloader.Request --- .../schabi/newpipe/extractor/downloader/Request.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java index 4bae8fc27..34f2a089d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java @@ -26,15 +26,15 @@ public class Request { this.dataToSend = dataToSend; this.localization = localization; - Map> headersToSet = null; - if (headers == null) headers = Collections.emptyMap(); - + final Map> actualHeaders = new LinkedHashMap<>(); + if (headers != null) { + actualHeaders.putAll(headers); + } if (automaticLocalizationHeader && localization != null) { - headersToSet = new LinkedHashMap<>(headersFromLocalization(localization)); - headersToSet.putAll(headers); + actualHeaders.putAll(headersFromLocalization(localization)); } - this.headers = Collections.unmodifiableMap(headersToSet == null ? headers : headersToSet); + this.headers = Collections.unmodifiableMap(actualHeaders); } private Request(Builder builder) {