package okhttp3; import d0.z.d.m; import f0.f0.g.c; import f0.v; import f0.y; import f0.z; import java.io.Closeable; import java.util.Objects; import okhttp3.Headers; /* compiled from: Response.kt */ public final class Response implements Closeable { public final z i; public final y j; public final String k; public final int l; public final v m; public final Headers n; public final ResponseBody o; public final Response p; public final Response q; public final Response r; /* renamed from: s reason: collision with root package name */ public final long f2855s; public final long t; public final c u; /* compiled from: Response.kt */ public static class a { public z a; public y b; /* renamed from: c reason: collision with root package name */ public int f2856c; public String d; public v e; public Headers.a f; public ResponseBody g; public Response h; public Response i; public Response j; public long k; public long l; public c m; public a() { this.f2856c = -1; this.f = new Headers.a(); } public a(Response response) { m.checkParameterIsNotNull(response, "response"); this.f2856c = -1; this.a = response.i; this.b = response.j; this.f2856c = response.l; this.d = response.k; this.e = response.m; this.f = response.n.e(); this.g = response.o; this.h = response.p; this.i = response.q; this.j = response.r; this.k = response.f2855s; this.l = response.t; this.m = response.u; } public Response a() { int i = this.f2856c; if (i >= 0) { z zVar = this.a; if (zVar != null) { y yVar = this.b; if (yVar != null) { String str = this.d; if (str != null) { return new Response(zVar, yVar, str, i, this.e, this.f.c(), this.g, this.h, this.i, this.j, this.k, this.l, this.m); } throw new IllegalStateException("message == null".toString()); } throw new IllegalStateException("protocol == null".toString()); } throw new IllegalStateException("request == null".toString()); } StringBuilder L = c.d.b.a.a.L("code < 0: "); L.append(this.f2856c); throw new IllegalStateException(L.toString().toString()); } public a b(Response response) { c("cacheResponse", response); this.i = response; return this; } public final void c(String str, Response response) { if (response != null) { boolean z2 = false; if (response.o == null) { if (response.p == null) { if (response.q == null) { if (response.r == null) { z2 = true; } if (!z2) { throw new IllegalArgumentException(c.d.b.a.a.u(str, ".priorResponse != null").toString()); } return; } throw new IllegalArgumentException(c.d.b.a.a.u(str, ".cacheResponse != null").toString()); } throw new IllegalArgumentException(c.d.b.a.a.u(str, ".networkResponse != null").toString()); } throw new IllegalArgumentException(c.d.b.a.a.u(str, ".body != null").toString()); } } public a d(Headers headers) { m.checkParameterIsNotNull(headers, "headers"); this.f = headers.e(); return this; } public a e(String str) { m.checkParameterIsNotNull(str, "message"); this.d = str; return this; } public a f(y yVar) { m.checkParameterIsNotNull(yVar, "protocol"); this.b = yVar; return this; } public a g(z zVar) { m.checkParameterIsNotNull(zVar, "request"); this.a = zVar; return this; } } public Response(z zVar, y yVar, String str, int i, v vVar, Headers headers, ResponseBody responseBody, Response response, Response response2, Response response3, long j, long j2, c cVar) { m.checkParameterIsNotNull(zVar, "request"); m.checkParameterIsNotNull(yVar, "protocol"); m.checkParameterIsNotNull(str, "message"); m.checkParameterIsNotNull(headers, "headers"); this.i = zVar; this.j = yVar; this.k = str; this.l = i; this.m = vVar; this.n = headers; this.o = responseBody; this.p = response; this.q = response2; this.r = response3; this.f2855s = j; this.t = j2; this.u = cVar; } public static String a(Response response, String str, String str2, int i) { int i2 = i & 2; Objects.requireNonNull(response); m.checkParameterIsNotNull(str, "name"); String c2 = response.n.c(str); if (c2 != null) { return c2; } return null; } public final boolean b() { int i = this.l; return 200 <= i && 299 >= i; } @Override // java.io.Closeable, java.lang.AutoCloseable public void close() { ResponseBody responseBody = this.o; if (responseBody != null) { responseBody.close(); return; } throw new IllegalStateException("response is not eligible for a body and must not be closed".toString()); } @Override // java.lang.Object public String toString() { StringBuilder L = c.d.b.a.a.L("Response{protocol="); L.append(this.j); L.append(", code="); L.append(this.l); L.append(", message="); L.append(this.k); L.append(", url="); L.append(this.i.b); L.append('}'); return L.toString(); } }