- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
128 lines
3.9 KiB
Java
128 lines
3.9 KiB
Java
package okhttp3;
|
|
|
|
import java.io.File;
|
|
import java.nio.charset.Charset;
|
|
import java.nio.charset.StandardCharsets;
|
|
import okhttp3.internal.Util;
|
|
import okio.BufferedSink;
|
|
import okio.ByteString;
|
|
import okio.Okio;
|
|
import okio.Source;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public abstract class RequestBody {
|
|
public abstract long contentLength();
|
|
|
|
public abstract MediaType contentType();
|
|
|
|
public boolean isDuplex() {
|
|
return false;
|
|
}
|
|
|
|
public boolean isOneShot() {
|
|
return false;
|
|
}
|
|
|
|
public abstract void writeTo(BufferedSink bufferedSink);
|
|
|
|
public static RequestBody create(MediaType mediaType, String str) {
|
|
Charset charset = StandardCharsets.UTF_8;
|
|
if (mediaType != null) {
|
|
Charset charset2 = mediaType.charset();
|
|
if (charset2 == null) {
|
|
mediaType = MediaType.parse(mediaType + "; charset=utf-8");
|
|
} else {
|
|
charset = charset2;
|
|
}
|
|
}
|
|
return create(mediaType, str.getBytes(charset));
|
|
}
|
|
|
|
public static RequestBody create(final MediaType mediaType, final ByteString byteString) {
|
|
return new RequestBody() { // from class: okhttp3.RequestBody.1
|
|
@Override // okhttp3.RequestBody
|
|
public MediaType contentType() {
|
|
return MediaType.this;
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public long contentLength() {
|
|
return byteString.size();
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public void writeTo(BufferedSink bufferedSink) {
|
|
bufferedSink.write(byteString);
|
|
}
|
|
};
|
|
}
|
|
|
|
public static RequestBody create(MediaType mediaType, byte[] bArr) {
|
|
return create(mediaType, bArr, 0, bArr.length);
|
|
}
|
|
|
|
public static RequestBody create(final MediaType mediaType, final byte[] bArr, final int i, final int i2) {
|
|
if (bArr == null) {
|
|
throw new NullPointerException("content == null");
|
|
}
|
|
Util.checkOffsetAndCount(bArr.length, i, i2);
|
|
return new RequestBody() { // from class: okhttp3.RequestBody.2
|
|
@Override // okhttp3.RequestBody
|
|
public long contentLength() {
|
|
return i2;
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public MediaType contentType() {
|
|
return MediaType.this;
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public void writeTo(BufferedSink bufferedSink) {
|
|
bufferedSink.write(bArr, i, i2);
|
|
}
|
|
};
|
|
}
|
|
|
|
public static RequestBody create(final MediaType mediaType, final File file) {
|
|
if (file == null) {
|
|
throw new NullPointerException("file == null");
|
|
}
|
|
return new RequestBody() { // from class: okhttp3.RequestBody.3
|
|
@Override // okhttp3.RequestBody
|
|
public MediaType contentType() {
|
|
return MediaType.this;
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public long contentLength() {
|
|
return file.length();
|
|
}
|
|
|
|
@Override // okhttp3.RequestBody
|
|
public void writeTo(BufferedSink bufferedSink) {
|
|
Source source = Okio.source(file);
|
|
try {
|
|
bufferedSink.writeAll(source);
|
|
if (source != null) {
|
|
source.close();
|
|
}
|
|
} catch (Throwable th) {
|
|
try {
|
|
throw th;
|
|
} catch (Throwable th2) {
|
|
if (source != null) {
|
|
try {
|
|
source.close();
|
|
} catch (Throwable th3) {
|
|
th.addSuppressed(th3);
|
|
}
|
|
}
|
|
throw th2;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|