Skip to content

Commit e4951a0

Browse files
Stypoxlitetex
authored andcommitted
Refactor code handling http headers in downloader.Request
1 parent 3769005 commit e4951a0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • extractor/src/main/java/org/schabi/newpipe/extractor/downloader

extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public Request(String httpMethod, String url, Map<String, List<String>> headers,
2626
this.dataToSend = dataToSend;
2727
this.localization = localization;
2828

29-
Map<String, List<String>> headersToSet = null;
30-
if (headers == null) headers = Collections.emptyMap();
31-
29+
final Map<String, List<String>> actualHeaders = new LinkedHashMap<>();
30+
if (headers != null) {
31+
actualHeaders.putAll(headers);
32+
}
3233
if (automaticLocalizationHeader && localization != null) {
33-
headersToSet = new LinkedHashMap<>(headersFromLocalization(localization));
34-
headersToSet.putAll(headers);
34+
actualHeaders.putAll(headersFromLocalization(localization));
3535
}
3636

37-
this.headers = Collections.unmodifiableMap(headersToSet == null ? headers : headersToSet);
37+
this.headers = Collections.unmodifiableMap(actualHeaders);
3838
}
3939

4040
private Request(Builder builder) {

0 commit comments

Comments
 (0)