52 lines
1.6 KiB
Java
52 lines
1.6 KiB
Java
|
package okhttp3.repackaged.internal;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collections;
|
||
|
import java.util.Comparator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.TreeMap;
|
||
|
import okhttp3.repackaged.Headers;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class JavaNetHeaders {
|
||
|
private static final Comparator<String> aji = new Comparator<String>() { // from class: okhttp3.repackaged.internal.JavaNetHeaders.1
|
||
|
@Override // java.util.Comparator
|
||
|
public final int compare(String str, String str2) {
|
||
|
if (str == str2) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (str == null) {
|
||
|
return -1;
|
||
|
}
|
||
|
if (str2 == null) {
|
||
|
return 1;
|
||
|
}
|
||
|
return String.CASE_INSENSITIVE_ORDER.compare(str, str2);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
private JavaNetHeaders() {
|
||
|
}
|
||
|
|
||
|
public static Map<String, List<String>> toMultimap(Headers headers, String str) {
|
||
|
TreeMap treeMap = new TreeMap(aji);
|
||
|
int size = headers.size();
|
||
|
for (int i = 0; i < size; i++) {
|
||
|
String name = headers.name(i);
|
||
|
String value = headers.value(i);
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
List list = (List) treeMap.get(name);
|
||
|
if (list != null) {
|
||
|
arrayList.addAll(list);
|
||
|
}
|
||
|
arrayList.add(value);
|
||
|
treeMap.put(name, Collections.unmodifiableList(arrayList));
|
||
|
}
|
||
|
if (str != null) {
|
||
|
treeMap.put(null, Collections.unmodifiableList(Collections.singletonList(str)));
|
||
|
}
|
||
|
return Collections.unmodifiableMap(treeMap);
|
||
|
}
|
||
|
}
|