package okhttp3; import d0.z.d.m; import f0.e0.c; import g0.g; import java.io.Closeable; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.Charset; import kotlin.jvm.internal.DefaultConstructorMarker; /* compiled from: ResponseBody.kt */ /* loaded from: classes3.dex */ public abstract class ResponseBody implements Closeable { public static final b j = new b(null); public Reader k; /* compiled from: ResponseBody.kt */ /* loaded from: classes3.dex */ public static final class a extends Reader { public boolean j; public Reader k; public final g l; public final Charset m; public a(g gVar, Charset charset) { m.checkParameterIsNotNull(gVar, "source"); m.checkParameterIsNotNull(charset, "charset"); this.l = gVar; this.m = charset; } @Override // java.io.Reader, java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { this.j = true; Reader reader = this.k; if (reader != null) { reader.close(); } else { this.l.close(); } } @Override // java.io.Reader public int read(char[] cArr, int i, int i2) throws IOException { m.checkParameterIsNotNull(cArr, "cbuf"); if (!this.j) { Reader reader = this.k; if (reader == null) { reader = new InputStreamReader(this.l.u0(), c.s(this.l, this.m)); this.k = reader; } return reader.read(cArr, i, i2); } throw new IOException("Stream closed"); } } /* compiled from: ResponseBody.kt */ /* loaded from: classes3.dex */ public static final class b { public b(DefaultConstructorMarker defaultConstructorMarker) { } } public abstract long a(); public abstract MediaType b(); public abstract g c(); @Override // java.io.Closeable, java.lang.AutoCloseable public void close() { c.d(c()); } public final String d() throws IOException { Charset charset; g c = c(); try { MediaType b2 = b(); if (b2 == null || (charset = b2.a(d0.g0.c.a)) == null) { charset = d0.g0.c.a; } th = null; return c.M(c.s(c, charset)); } finally { try { throw th; } finally { } } } }