Rabbit-R1/switch port/java/sources/okhttp3/FormBody.java

161 lines
8.8 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package okhttp3;
import io.sentry.protocol.OperatingSystem;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import kotlin.Deprecated;
import kotlin.DeprecationLevel;
import kotlin.Metadata;
import kotlin.ReplaceWith;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.HttpUrl;
import okhttp3.internal.Util;
import okio.Buffer;
import okio.BufferedSink;
/* compiled from: FormBody.kt */
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\u0018\u0000 \u001c2\u00020\u0001:\u0002\u001b\u001cB#\b\u0000\u0012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003\u0012\f\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003¢\u0006\u0002\u0010\u0006J\b\u0010\n\u001a\u00020\u000bH\u0016J\b\u0010\f\u001a\u00020\rH\u0016J\u000e\u0010\u000e\u001a\u00020\u00042\u0006\u0010\u000f\u001a\u00020\bJ\u000e\u0010\u0010\u001a\u00020\u00042\u0006\u0010\u000f\u001a\u00020\bJ\u000e\u0010\u0011\u001a\u00020\u00042\u0006\u0010\u000f\u001a\u00020\bJ\r\u0010\u0007\u001a\u00020\bH\u0007¢\u0006\u0002\b\u0012J\u000e\u0010\u0013\u001a\u00020\u00042\u0006\u0010\u000f\u001a\u00020\bJ\u001a\u0010\u0014\u001a\u00020\u000b2\b\u0010\u0015\u001a\u0004\u0018\u00010\u00162\u0006\u0010\u0017\u001a\u00020\u0018H\u0002J\u0010\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u0015\u001a\u00020\u0016H\u0016R\u0014\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u0007\u001a\u00020\b8G¢\u0006\u0006\u001a\u0004\b\u0007\u0010\\u0006\u001d"}, d2 = {"Lokhttp3/FormBody;", "Lokhttp3/RequestBody;", "encodedNames", "", "", "encodedValues", "(Ljava/util/List;Ljava/util/List;)V", "size", "", "()I", "contentLength", "", "contentType", "Lokhttp3/MediaType;", "encodedName", "index", "encodedValue", "name", "-deprecated_size", "value", "writeOrCountBytes", "sink", "Lokio/BufferedSink;", "countBytes", "", "writeTo", "", "Builder", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
/* loaded from: classes3.dex */
public final class FormBody extends RequestBody {
private final List<String> encodedNames;
private final List<String> encodedValues;
private static final MediaType CONTENT_TYPE = MediaType.INSTANCE.get("application/x-www-form-urlencoded");
@Override // okhttp3.RequestBody
/* renamed from: contentType */
public MediaType get$contentType() {
return CONTENT_TYPE;
}
public FormBody(List<String> encodedNames, List<String> encodedValues) {
Intrinsics.checkNotNullParameter(encodedNames, "encodedNames");
Intrinsics.checkNotNullParameter(encodedValues, "encodedValues");
this.encodedNames = Util.toImmutableList(encodedNames);
this.encodedValues = Util.toImmutableList(encodedValues);
}
public final int size() {
return this.encodedNames.size();
}
@Deprecated(level = DeprecationLevel.ERROR, message = "moved to val", replaceWith = @ReplaceWith(expression = "size", imports = {}))
/* renamed from: -deprecated_size, reason: not valid java name */
public final int m7310deprecated_size() {
return size();
}
public final String encodedName(int index) {
return this.encodedNames.get(index);
}
public final String name(int index) {
return HttpUrl.Companion.percentDecode$okhttp$default(HttpUrl.INSTANCE, encodedName(index), 0, 0, true, 3, null);
}
public final String encodedValue(int index) {
return this.encodedValues.get(index);
}
public final String value(int index) {
return HttpUrl.Companion.percentDecode$okhttp$default(HttpUrl.INSTANCE, encodedValue(index), 0, 0, true, 3, null);
}
@Override // okhttp3.RequestBody
public long contentLength() {
return writeOrCountBytes(null, true);
}
@Override // okhttp3.RequestBody
public void writeTo(BufferedSink sink) throws IOException {
Intrinsics.checkNotNullParameter(sink, "sink");
writeOrCountBytes(sink, false);
}
private final long writeOrCountBytes(BufferedSink sink, boolean countBytes) {
Buffer buffer;
if (countBytes) {
buffer = new Buffer();
} else {
Intrinsics.checkNotNull(sink);
buffer = sink.getBuffer();
}
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 (!countBytes) {
return 0L;
}
long size2 = buffer.size();
buffer.clear();
return size2;
}
/* compiled from: FormBody.kt */
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010!\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\u0018\u00002\u00020\u0001B\u0013\b\u0007\u0012\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u0003¢\u0006\u0002\u0010\u0004J\u0016\u0010\t\u001a\u00020\u00002\u0006\u0010\n\u001a\u00020\u00072\u0006\u0010\u000b\u001a\u00020\u0007J\u0016\u0010\f\u001a\u00020\u00002\u0006\u0010\n\u001a\u00020\u00072\u0006\u0010\u000b\u001a\u00020\u0007J\u0006\u0010\r\u001a\u00020\u000eR\u0010\u0010\u0002\u001a\u0004\u0018\u00010\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\b\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u000f"}, d2 = {"Lokhttp3/FormBody$Builder;", "", "charset", "Ljava/nio/charset/Charset;", "(Ljava/nio/charset/Charset;)V", "names", "", "", "values", "add", "name", "value", "addEncoded", OperatingSystem.JsonKeys.BUILD, "Lokhttp3/FormBody;", "okhttp"}, k = 1, mv = {1, 4, 0})
/* loaded from: classes3.dex */
public static final class Builder {
private final Charset charset;
private final List<String> names;
private final List<String> values;
/* JADX WARN: Multi-variable type inference failed */
public Builder() {
this(null, 1, 0 == true ? 1 : 0);
}
public Builder(Charset charset) {
this.charset = charset;
this.names = new ArrayList();
this.values = new ArrayList();
}
/* JADX WARN: Illegal instructions before constructor call */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public /* synthetic */ Builder(java.nio.charset.Charset r1, int r2, kotlin.jvm.internal.DefaultConstructorMarker r3) {
/*
r0 = this;
r2 = r2 & 1
if (r2 == 0) goto L8
r1 = 0
r2 = r1
java.nio.charset.Charset r2 = (java.nio.charset.Charset) r2
L8:
r0.<init>(r1)
return
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.FormBody.Builder.<init>(java.nio.charset.Charset, int, kotlin.jvm.internal.DefaultConstructorMarker):void");
}
public final Builder add(String name, String value) {
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(value, "value");
this.names.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.INSTANCE, name, 0, 0, HttpUrl.FORM_ENCODE_SET, false, false, true, false, this.charset, 91, null));
this.values.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.INSTANCE, value, 0, 0, HttpUrl.FORM_ENCODE_SET, false, false, true, false, this.charset, 91, null));
return this;
}
public final Builder addEncoded(String name, String value) {
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(value, "value");
this.names.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.INSTANCE, name, 0, 0, HttpUrl.FORM_ENCODE_SET, true, false, true, false, this.charset, 83, null));
this.values.add(HttpUrl.Companion.canonicalize$okhttp$default(HttpUrl.INSTANCE, value, 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);
}
}
}