package okhttp3; import d0.g0.c; import d0.z.d.m; import f0.a0; import f0.b0; 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 */ public final /* synthetic */ int f2872c; public final /* synthetic */ int d; public a(byte[] bArr, MediaType mediaType, int i, int i2) { this.a = bArr; this.b = mediaType; this.f2872c = i; this.d = i2; } @Override // okhttp3.RequestBody public long contentLength() { return (long) this.f2872c; } @Override // okhttp3.RequestBody public MediaType contentType() { return this.b; } @Override // okhttp3.RequestBody public void writeTo(BufferedSink bufferedSink) { m.checkParameterIsNotNull(bufferedSink, "sink"); bufferedSink.write(this.a, this.d, this.f2872c); } } 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) { MediaType.a aVar = MediaType.f2869c; 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"); f0.f0.c.c((long) bArr.length, (long) i, (long) i2); return new a(bArr, mediaType, i2, i); } } public static final RequestBody create(File file, MediaType mediaType) { Objects.requireNonNull(Companion); m.checkParameterIsNotNull(file, "$this$asRequestBody"); return new a0(file, mediaType); } 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"); return new a0(file, mediaType); } 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"); return new b0(byteString, mediaType); } 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"); return new b0(byteString, mediaType); } 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; }