Files
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

125 lines
3.9 KiB
Java

package com.mbridge.msdk.thrid.okhttp;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okio.Buffer;
import com.mbridge.msdk.thrid.okio.BufferedSink;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes4.dex */
public final class FormBody extends RequestBody {
private static final MediaType CONTENT_TYPE = MediaType.get("application/x-www-form-urlencoded");
private final List<String> encodedNames;
private final List<String> encodedValues;
@Override // com.mbridge.msdk.thrid.okhttp.RequestBody
public MediaType contentType() {
return CONTENT_TYPE;
}
public FormBody(List<String> list, List<String> list2) {
this.encodedNames = Util.immutableList(list);
this.encodedValues = Util.immutableList(list2);
}
public int size() {
return this.encodedNames.size();
}
public String encodedName(int i) {
return this.encodedNames.get(i);
}
public String name(int i) {
return HttpUrl.percentDecode(encodedName(i), true);
}
public String encodedValue(int i) {
return this.encodedValues.get(i);
}
public String value(int i) {
return HttpUrl.percentDecode(encodedValue(i), true);
}
@Override // com.mbridge.msdk.thrid.okhttp.RequestBody
public long contentLength() {
return writeOrCountBytes(null, true);
}
@Override // com.mbridge.msdk.thrid.okhttp.RequestBody
public void writeTo(BufferedSink bufferedSink) throws IOException {
writeOrCountBytes(bufferedSink, false);
}
private long writeOrCountBytes(BufferedSink bufferedSink, boolean z) {
Buffer buffer;
if (z) {
buffer = new Buffer();
} else {
buffer = bufferedSink.buffer();
}
int size = this.encodedNames.size();
for (int i = 0; i < size; i++) {
if (i > 0) {
buffer.writeByte(38);
}
buffer.writeUtf8(this.encodedNames.get(i));
buffer.writeByte(61);
buffer.writeUtf8(this.encodedValues.get(i));
}
if (!z) {
return 0L;
}
long size2 = buffer.size();
buffer.clear();
return size2;
}
public static final class Builder {
private final Charset charset;
private final List<String> names;
private final List<String> values;
public Builder() {
this(null);
}
public Builder(Charset charset) {
this.names = new ArrayList();
this.values = new ArrayList();
this.charset = charset;
}
public Builder add(String str, String str2) {
if (str == null) {
throw new NullPointerException("name == null");
}
if (str2 == null) {
throw new NullPointerException("value == null");
}
this.names.add(HttpUrl.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#&!$(),~", false, false, true, true, this.charset));
this.values.add(HttpUrl.canonicalize(str2, " \"':;<=>@[]^`{}|/\\?#&!$(),~", false, false, true, true, this.charset));
return this;
}
public Builder addEncoded(String str, String str2) {
if (str == null) {
throw new NullPointerException("name == null");
}
if (str2 == null) {
throw new NullPointerException("value == null");
}
this.names.add(HttpUrl.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#&!$(),~", true, false, true, true, this.charset));
this.values.add(HttpUrl.canonicalize(str2, " \"':;<=>@[]^`{}|/\\?#&!$(),~", true, false, true, true, this.charset));
return this;
}
public FormBody build() {
return new FormBody(this.names, this.values);
}
}
}