150 lines
4.9 KiB
Java
150 lines
4.9 KiB
Java
package okhttp3;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.charset.Charset;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import o.C14953gcr;
|
|
import o.C14957gcv;
|
|
import o.C15111ghZ;
|
|
import o.InterfaceC15148gic;
|
|
import okhttp3.HttpUrl;
|
|
import okhttp3.internal.Util;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class FormBody extends RequestBody {
|
|
private final List<String> encodedNames;
|
|
private final List<String> encodedValues;
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final MediaType CONTENT_TYPE = MediaType.Companion.get("application/x-www-form-urlencoded");
|
|
|
|
public FormBody(List<String> list, List<String> list2) {
|
|
C14957gcv.e(list, "");
|
|
C14957gcv.e(list2, "");
|
|
this.encodedNames = Util.toImmutableList(list);
|
|
this.encodedValues = Util.toImmutableList(list2);
|
|
}
|
|
|
|
public final int size() {
|
|
return this.encodedNames.size();
|
|
}
|
|
|
|
/* renamed from: -deprecated_size, reason: not valid java name */
|
|
public final int m397deprecated_size() {
|
|
return size();
|
|
}
|
|
|
|
public final String encodedName(int i) {
|
|
return this.encodedNames.get(i);
|
|
}
|
|
|
|
public final String name(int i) {
|
|
return HttpUrl.Companion.percentDecode$okhttp$default(HttpUrl.Companion, encodedName(i), 0, 0, true, 3, null);
|
|
}
|
|
|
|
public final String encodedValue(int i) {
|
|
return this.encodedValues.get(i);
|
|
}
|
|
|
|
public final String value(int i) {
|
|
return HttpUrl.Companion.percentDecode$okhttp$default(HttpUrl.Companion, encodedValue(i), 0, 0, true, 3, null);
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public final long contentLength() {
|
|
return writeOrCountBytes(null, true);
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public final void writeTo(InterfaceC15148gic interfaceC15148gic) throws IOException {
|
|
C14957gcv.e(interfaceC15148gic, "");
|
|
writeOrCountBytes(interfaceC15148gic, false);
|
|
}
|
|
|
|
private final long writeOrCountBytes(InterfaceC15148gic interfaceC15148gic, boolean z) {
|
|
C15111ghZ i;
|
|
if (z) {
|
|
i = new C15111ghZ();
|
|
} else {
|
|
C14957gcv.e(interfaceC15148gic);
|
|
i = interfaceC15148gic.i();
|
|
}
|
|
int size = this.encodedNames.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
if (i2 > 0) {
|
|
i.b(38);
|
|
}
|
|
String str = this.encodedNames.get(i2);
|
|
C14957gcv.e(str, "");
|
|
i.c(str, 0, str.length());
|
|
i.b(61);
|
|
String str2 = this.encodedValues.get(i2);
|
|
C14957gcv.e(str2, "");
|
|
i.c(str2, 0, str2.length());
|
|
}
|
|
if (!z) {
|
|
return 0L;
|
|
}
|
|
long j = i.c;
|
|
i.j(i.c);
|
|
return j;
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static final class Builder {
|
|
private final Charset charset;
|
|
private final List<String> names;
|
|
private final List<String> values;
|
|
|
|
public Builder(Charset charset) {
|
|
this.charset = charset;
|
|
this.names = new ArrayList();
|
|
this.values = new ArrayList();
|
|
}
|
|
|
|
public /* synthetic */ Builder(Charset charset, int i, C14953gcr c14953gcr) {
|
|
this((i & 1) != 0 ? null : charset);
|
|
}
|
|
|
|
public final Builder add(String str, String str2) {
|
|
C14957gcv.e(str, "");
|
|
C14957gcv.e(str2, "");
|
|
this.names.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.FORM_ENCODE_SET, false, false, true, false, this.charset, 91, null));
|
|
this.values.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.Companion, str2, 0, 0, HttpUrl.FORM_ENCODE_SET, false, false, true, false, this.charset, 91, null));
|
|
return this;
|
|
}
|
|
|
|
public final Builder addEncoded(String str, String str2) {
|
|
C14957gcv.e(str, "");
|
|
C14957gcv.e(str2, "");
|
|
this.names.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.FORM_ENCODE_SET, true, false, true, false, this.charset, 83, null));
|
|
this.values.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.Companion, str2, 0, 0, HttpUrl.FORM_ENCODE_SET, true, false, true, false, this.charset, 83, null));
|
|
return this;
|
|
}
|
|
|
|
public final FormBody build() {
|
|
return new FormBody(this.names, this.values);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public Builder() {
|
|
this(null, 1, 0 == true ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(C14953gcr c14953gcr) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public final MediaType contentType() {
|
|
return CONTENT_TYPE;
|
|
}
|
|
}
|