2021-06-27 20:44:35 +00:00
|
|
|
package okhttp3;
|
|
|
|
|
2021-10-19 23:48:27 +00:00
|
|
|
import c0.g0.c;
|
|
|
|
import c0.z.d.m;
|
|
|
|
import e0.a0;
|
|
|
|
import e0.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 */
|
|
|
|
public abstract class RequestBody {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
|
|
|
|
/* compiled from: RequestBody.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
|
|
|
|
/* compiled from: RequestBody.kt */
|
|
|
|
public static final class a extends RequestBody {
|
|
|
|
public final /* synthetic */ byte[] a;
|
|
|
|
public final /* synthetic */ MediaType b;
|
|
|
|
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
2021-11-03 22:42:40 +00:00
|
|
|
public final /* synthetic */ int f3130c;
|
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;
|
|
|
|
this.b = mediaType;
|
2021-11-03 22:42:40 +00:00
|
|
|
this.f3130c = i;
|
2021-06-27 20:44:35 +00:00
|
|
|
this.d = i2;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.RequestBody
|
|
|
|
public long contentLength() {
|
2021-11-03 22:42:40 +00:00
|
|
|
return (long) this.f3130c;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.RequestBody
|
|
|
|
public MediaType contentType() {
|
|
|
|
return this.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.RequestBody
|
|
|
|
public void writeTo(BufferedSink bufferedSink) {
|
|
|
|
m.checkParameterIsNotNull(bufferedSink, "sink");
|
2021-11-03 22:42:40 +00:00
|
|
|
bufferedSink.write(this.a, this.d, this.f3130c);
|
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-11-03 22:42:40 +00:00
|
|
|
MediaType.a aVar = MediaType.f3125c;
|
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");
|
2021-10-19 23:48:27 +00:00
|
|
|
e0.e0.c.c((long) bArr.length, (long) i, (long) 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 {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract MediaType contentType();
|
|
|
|
|
|
|
|
public boolean isDuplex() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOneShot() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void writeTo(BufferedSink bufferedSink) throws IOException;
|
|
|
|
}
|