2021-06-27 20:44:35 +00:00
|
|
|
package okhttp3;
|
|
|
|
|
2021-11-08 18:25:28 +00:00
|
|
|
import d0.g0.c;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import f0.a0;
|
|
|
|
import f0.z;
|
2021-06-27 20:44:35 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import okhttp3.MediaType;
|
|
|
|
import okio.BufferedSink;
|
|
|
|
import okio.ByteString;
|
|
|
|
/* compiled from: RequestBody.kt */
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public abstract class RequestBody {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
|
|
|
|
/* compiled from: RequestBody.kt */
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public static final class Companion {
|
|
|
|
|
|
|
|
/* compiled from: RequestBody.kt */
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public static final class a extends RequestBody {
|
|
|
|
public final /* synthetic */ byte[] a;
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-03-30 16:43:10 +00:00
|
|
|
public final /* synthetic */ MediaType f3796b;
|
2021-12-21 23:37:30 +00:00
|
|
|
public final /* synthetic */ int c;
|
2021-06-27 20:44:35 +00:00
|
|
|
public final /* synthetic */ int d;
|
|
|
|
|
|
|
|
public a(byte[] bArr, MediaType mediaType, int i, int i2) {
|
|
|
|
this.a = bArr;
|
2022-03-30 16:43:10 +00:00
|
|
|
this.f3796b = mediaType;
|
2021-12-21 23:37:30 +00:00
|
|
|
this.c = i;
|
2021-06-27 20:44:35 +00:00
|
|
|
this.d = i2;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.RequestBody
|
|
|
|
public long contentLength() {
|
2022-03-02 20:59:20 +00:00
|
|
|
return this.c;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.RequestBody
|
|
|
|
public MediaType contentType() {
|
2022-03-30 16:43:10 +00:00
|
|
|
return this.f3796b;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.RequestBody
|
|
|
|
public void writeTo(BufferedSink bufferedSink) {
|
|
|
|
m.checkParameterIsNotNull(bufferedSink, "sink");
|
2021-12-21 23:37:30 +00:00
|
|
|
bufferedSink.write(this.a, this.d, this.c);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RequestBody c(Companion companion, MediaType mediaType, byte[] bArr, int i, int i2, int i3) {
|
|
|
|
if ((i3 & 4) != 0) {
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
if ((i3 & 8) != 0) {
|
|
|
|
i2 = bArr.length;
|
|
|
|
}
|
|
|
|
Objects.requireNonNull(companion);
|
|
|
|
m.checkParameterIsNotNull(bArr, "content");
|
|
|
|
return companion.b(bArr, mediaType, i, i2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ RequestBody d(Companion companion, byte[] bArr, MediaType mediaType, int i, int i2, int i3) {
|
|
|
|
if ((i3 & 1) != 0) {
|
|
|
|
mediaType = null;
|
|
|
|
}
|
|
|
|
if ((i3 & 2) != 0) {
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
if ((i3 & 4) != 0) {
|
|
|
|
i2 = bArr.length;
|
|
|
|
}
|
|
|
|
return companion.b(bArr, mediaType, i, i2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final RequestBody a(String str, MediaType mediaType) {
|
|
|
|
m.checkParameterIsNotNull(str, "$this$toRequestBody");
|
|
|
|
Charset charset = c.a;
|
|
|
|
if (mediaType != null) {
|
|
|
|
Pattern pattern = MediaType.a;
|
|
|
|
Charset a2 = mediaType.a(null);
|
|
|
|
if (a2 == null) {
|
2021-12-21 23:37:30 +00:00
|
|
|
MediaType.a aVar = MediaType.c;
|
2021-06-27 20:44:35 +00:00
|
|
|
mediaType = MediaType.a.b(mediaType + "; charset=utf-8");
|
|
|
|
} else {
|
|
|
|
charset = a2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
byte[] bytes = str.getBytes(charset);
|
|
|
|
m.checkExpressionValueIsNotNull(bytes, "(this as java.lang.String).getBytes(charset)");
|
|
|
|
return b(bytes, mediaType, 0, bytes.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final RequestBody b(byte[] bArr, MediaType mediaType, int i, int i2) {
|
|
|
|
m.checkParameterIsNotNull(bArr, "$this$toRequestBody");
|
2022-03-02 20:59:20 +00:00
|
|
|
f0.e0.c.c(bArr.length, i, i2);
|
2021-06-27 20:44:35 +00:00
|
|
|
return new a(bArr, mediaType, i2, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(File file, MediaType mediaType) {
|
|
|
|
Objects.requireNonNull(Companion);
|
|
|
|
m.checkParameterIsNotNull(file, "$this$asRequestBody");
|
2021-08-24 17:45:16 +00:00
|
|
|
return new z(file, mediaType);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(String str, MediaType mediaType) {
|
|
|
|
return Companion.a(str, mediaType);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(MediaType mediaType, File file) {
|
|
|
|
Objects.requireNonNull(Companion);
|
|
|
|
m.checkParameterIsNotNull(file, "file");
|
|
|
|
m.checkParameterIsNotNull(file, "$this$asRequestBody");
|
2021-08-24 17:45:16 +00:00
|
|
|
return new z(file, mediaType);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(MediaType mediaType, String str) {
|
|
|
|
Companion companion = Companion;
|
|
|
|
Objects.requireNonNull(companion);
|
|
|
|
m.checkParameterIsNotNull(str, "content");
|
|
|
|
return companion.a(str, mediaType);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(MediaType mediaType, ByteString byteString) {
|
|
|
|
Objects.requireNonNull(Companion);
|
|
|
|
m.checkParameterIsNotNull(byteString, "content");
|
|
|
|
m.checkParameterIsNotNull(byteString, "$this$toRequestBody");
|
2021-08-24 17:45:16 +00:00
|
|
|
return new a0(byteString, mediaType);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(MediaType mediaType, byte[] bArr) {
|
|
|
|
return Companion.c(Companion, mediaType, bArr, 0, 0, 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(MediaType mediaType, byte[] bArr, int i) {
|
|
|
|
return Companion.c(Companion, mediaType, bArr, i, 0, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(MediaType mediaType, byte[] bArr, int i, int i2) {
|
|
|
|
Companion companion = Companion;
|
|
|
|
Objects.requireNonNull(companion);
|
|
|
|
m.checkParameterIsNotNull(bArr, "content");
|
|
|
|
return companion.b(bArr, mediaType, i, i2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(ByteString byteString, MediaType mediaType) {
|
|
|
|
Objects.requireNonNull(Companion);
|
|
|
|
m.checkParameterIsNotNull(byteString, "$this$toRequestBody");
|
2021-08-24 17:45:16 +00:00
|
|
|
return new a0(byteString, mediaType);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(byte[] bArr) {
|
|
|
|
return Companion.d(Companion, bArr, null, 0, 0, 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(byte[] bArr, MediaType mediaType) {
|
|
|
|
return Companion.d(Companion, bArr, mediaType, 0, 0, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(byte[] bArr, MediaType mediaType, int i) {
|
|
|
|
return Companion.d(Companion, bArr, mediaType, i, 0, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final RequestBody create(byte[] bArr, MediaType mediaType, int i, int i2) {
|
|
|
|
return Companion.b(bArr, mediaType, i, i2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public long contentLength() throws IOException {
|
2022-03-02 20:59:20 +00:00
|
|
|
return -1L;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public abstract MediaType contentType();
|
|
|
|
|
|
|
|
public boolean isDuplex() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOneShot() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void writeTo(BufferedSink bufferedSink) throws IOException;
|
|
|
|
}
|