2021-08-03 07:33:18 +00:00
|
|
|
package okhttp3;
|
|
|
|
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
2021-11-02 06:38:17 +00:00
|
|
|
import d0.d0.f;
|
|
|
|
import d0.g0.t;
|
|
|
|
import d0.g0.w;
|
|
|
|
import d0.o;
|
|
|
|
import d0.t.r;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import f0.e0.c;
|
2021-08-03 07:33:18 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import kotlin.Pair;
|
|
|
|
import kotlin.TypeCastException;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import kotlin.ranges.IntProgression;
|
|
|
|
/* compiled from: Headers.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-11-02 06:38:17 +00:00
|
|
|
public final class Headers implements Iterable<Pair<? extends String, ? extends String>>, d0.z.d.g0.a {
|
2021-12-02 18:53:44 +00:00
|
|
|
public static final b j = new b(null);
|
|
|
|
public final String[] k;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
/* compiled from: Headers.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public static final class a {
|
|
|
|
public final List<String> a = new ArrayList(20);
|
|
|
|
|
|
|
|
public final a a(String str, String str2) {
|
2021-08-09 22:51:56 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkParameterIsNotNull(str2, "value");
|
2021-12-02 18:53:44 +00:00
|
|
|
b bVar = Headers.j;
|
2021-08-03 07:33:18 +00:00
|
|
|
bVar.a(str);
|
|
|
|
bVar.b(str2, str);
|
|
|
|
b(str, str2);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final a b(String str, String str2) {
|
2021-08-09 22:51:56 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkParameterIsNotNull(str2, "value");
|
|
|
|
this.a.add(str);
|
|
|
|
this.a.add(w.trim(str2).toString());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Headers c() {
|
|
|
|
Object[] array = this.a.toArray(new String[0]);
|
|
|
|
if (array != null) {
|
|
|
|
return new Headers((String[]) array, null);
|
|
|
|
}
|
|
|
|
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
|
|
|
|
}
|
|
|
|
|
|
|
|
public final a d(String str) {
|
2021-08-09 22:51:56 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-08-03 07:33:18 +00:00
|
|
|
int i = 0;
|
|
|
|
while (i < this.a.size()) {
|
|
|
|
if (t.equals(str, this.a.get(i), true)) {
|
|
|
|
this.a.remove(i);
|
|
|
|
this.a.remove(i);
|
|
|
|
i -= 2;
|
|
|
|
}
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: Headers.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public static final class b {
|
|
|
|
public b(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void a(String str) {
|
|
|
|
if (str.length() > 0) {
|
|
|
|
int length = str.length();
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
char charAt = str.charAt(i);
|
|
|
|
if (!('!' <= charAt && '~' >= charAt)) {
|
|
|
|
throw new IllegalArgumentException(c.j("Unexpected char %#04x at %d in header name: %s", Integer.valueOf(charAt), Integer.valueOf(i), str).toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
throw new IllegalArgumentException("name is empty".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void b(String str, String str2) {
|
|
|
|
int length = str.length();
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
char charAt = str.charAt(i);
|
|
|
|
if (!(charAt == '\t' || (' ' <= charAt && '~' >= charAt))) {
|
|
|
|
throw new IllegalArgumentException(c.j("Unexpected char %#04x at %d in %s value: %s", Integer.valueOf(charAt), Integer.valueOf(i), str2, str).toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Headers c(String... strArr) {
|
|
|
|
m.checkParameterIsNotNull(strArr, "namesAndValues");
|
|
|
|
if (strArr.length % 2 == 0) {
|
|
|
|
Object clone = strArr.clone();
|
|
|
|
if (clone != null) {
|
|
|
|
String[] strArr2 = (String[]) clone;
|
|
|
|
int length = strArr2.length;
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
if (strArr2[i] != null) {
|
|
|
|
String str = strArr2[i];
|
|
|
|
if (str != null) {
|
|
|
|
strArr2[i] = w.trim(str).toString();
|
|
|
|
} else {
|
|
|
|
throw new TypeCastException("null cannot be cast to non-null type kotlin.CharSequence");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
throw new IllegalArgumentException("Headers cannot be null".toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IntProgression step = f.step(f.until(0, strArr2.length), 2);
|
|
|
|
int first = step.getFirst();
|
|
|
|
int last = step.getLast();
|
|
|
|
int step2 = step.getStep();
|
|
|
|
if (step2 < 0 ? first >= last : first <= last) {
|
|
|
|
while (true) {
|
|
|
|
String str2 = strArr2[first];
|
|
|
|
String str3 = strArr2[first + 1];
|
|
|
|
a(str2);
|
|
|
|
b(str3, str2);
|
|
|
|
if (first == last) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
first += step2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new Headers(strArr2, null);
|
|
|
|
}
|
|
|
|
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<kotlin.String>");
|
|
|
|
}
|
|
|
|
throw new IllegalArgumentException("Expected alternating header names and values".toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Headers(String[] strArr, DefaultConstructorMarker defaultConstructorMarker) {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.k = strArr;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final String c(String str) {
|
2021-08-09 22:51:56 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-12-02 18:53:44 +00:00
|
|
|
String[] strArr = this.k;
|
2021-08-03 07:33:18 +00:00
|
|
|
IntProgression step = f.step(f.downTo(strArr.length - 2, 0), 2);
|
|
|
|
int first = step.getFirst();
|
|
|
|
int last = step.getLast();
|
|
|
|
int step2 = step.getStep();
|
|
|
|
if (step2 < 0 ? first >= last : first <= last) {
|
|
|
|
while (!t.equals(str, strArr[first], true)) {
|
|
|
|
if (first != last) {
|
|
|
|
first += step2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strArr[first + 1];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-12-02 18:53:44 +00:00
|
|
|
public final String d(int i) {
|
|
|
|
return this.k[i * 2];
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final a e() {
|
|
|
|
a aVar = new a();
|
2021-12-02 18:53:44 +00:00
|
|
|
r.addAll(aVar.a, this.k);
|
2021-08-03 07:33:18 +00:00
|
|
|
return aVar;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
2021-12-02 18:53:44 +00:00
|
|
|
return (obj instanceof Headers) && Arrays.equals(this.k, ((Headers) obj).k);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 18:53:44 +00:00
|
|
|
public final String g(int i) {
|
|
|
|
return this.k[(i * 2) + 1];
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return Arrays.hashCode(this.k);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.lang.Iterable
|
|
|
|
public Iterator<Pair<? extends String, ? extends String>> iterator() {
|
|
|
|
int size = size();
|
|
|
|
Pair[] pairArr = new Pair[size];
|
2021-12-02 18:53:44 +00:00
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
pairArr[i] = o.to(d(i), g(i));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-11-02 06:38:17 +00:00
|
|
|
return d0.z.d.c.iterator(pairArr);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final int size() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return this.k.length / 2;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
int size = size();
|
2021-12-02 18:53:44 +00:00
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
sb.append(d(i));
|
2021-08-03 07:33:18 +00:00
|
|
|
sb.append(": ");
|
2021-12-02 18:53:44 +00:00
|
|
|
sb.append(g(i));
|
2021-08-03 07:33:18 +00:00
|
|
|
sb.append("\n");
|
|
|
|
}
|
|
|
|
String sb2 = sb.toString();
|
|
|
|
m.checkExpressionValueIsNotNull(sb2, "StringBuilder().apply(builderAction).toString()");
|
|
|
|
return sb2;
|
|
|
|
}
|
|
|
|
}
|