Refactor code handling http headers in downloader.Request

This commit is contained in:
Stypox 2022-03-17 16:19:06 +01:00 committed by litetex
parent 37690058d2
commit e4951a0623
1 changed files with 6 additions and 6 deletions

View File

@ -26,15 +26,15 @@ public class Request {
this.dataToSend = dataToSend;
this.localization = localization;
Map<String, List<String>> headersToSet = null;
if (headers == null) headers = Collections.emptyMap();
final Map<String, List<String>> 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) {