what-the-bank/sources/okhttp3/repackaged/FormBody.java

109 lines
3.0 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.repackaged;
import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import o.giM;
import o.giO;
import okhttp3.repackaged.internal.Util;
/* loaded from: classes6.dex */
public final class FormBody extends RequestBody {
private static final MediaType ahB = MediaType.parse("application/x-www-form-urlencoded");
private final List<String> ahC;
private final List<String> ahD;
private FormBody(List<String> list, List<String> list2) {
this.ahC = Util.immutableList(list);
this.ahD = Util.immutableList(list2);
}
public final int size() {
return this.ahC.size();
}
public final String encodedName(int i) {
return this.ahC.get(i);
}
public final String name(int i) {
return HttpUrl.percentDecode(encodedName(i), true);
}
public final String encodedValue(int i) {
return this.ahD.get(i);
}
public final String value(int i) {
return HttpUrl.percentDecode(encodedValue(i), true);
}
@Override // okhttp3.repackaged.RequestBody
public final long contentLength() {
return a(null, true);
}
@Override // okhttp3.repackaged.RequestBody
public final void writeTo(giO gio) throws IOException {
a(gio, false);
}
private long a(giO gio, boolean z) {
giM b;
if (z) {
b = new giM();
} else {
b = gio.b();
}
int size = this.ahC.size();
for (int i = 0; i < size; i++) {
if (i > 0) {
b.b(38);
}
String str = this.ahC.get(i);
b.b(str, 0, str.length());
b.b(61);
String str2 = this.ahD.get(i);
b.b(str2, 0, str2.length());
}
if (!z) {
return 0L;
}
long j = b.a;
try {
b.f(b.a);
return j;
} catch (EOFException e) {
throw new AssertionError(e);
}
}
/* loaded from: classes6.dex */
public static final class Builder {
private final List<String> ahE = new ArrayList();
private final List<String> ahF = new ArrayList();
public final Builder add(String str, String str2) {
this.ahE.add(HttpUrl.canonicalize(str, okhttp3.HttpUrl.FORM_ENCODE_SET, false, false, true, true));
this.ahF.add(HttpUrl.canonicalize(str2, okhttp3.HttpUrl.FORM_ENCODE_SET, false, false, true, true));
return this;
}
public final Builder addEncoded(String str, String str2) {
this.ahE.add(HttpUrl.canonicalize(str, okhttp3.HttpUrl.FORM_ENCODE_SET, true, false, true, true));
this.ahF.add(HttpUrl.canonicalize(str2, okhttp3.HttpUrl.FORM_ENCODE_SET, true, false, true, true));
return this;
}
public final FormBody build() {
return new FormBody(this.ahE, this.ahF);
}
}
@Override // okhttp3.repackaged.RequestBody
public final MediaType contentType() {
return ahB;
}
}