package l5; import h5.d0; import h5.g0; import h5.h0; import h5.i0; import h5.l0; import h5.n0; import h5.v; import java.net.ProtocolException; /* loaded from: classes2.dex */ public final class b implements d0 { /* renamed from: a, reason: collision with root package name */ private final boolean f11599a; static final class a extends v { /* renamed from: b, reason: collision with root package name */ long f11600b; a(n0 n0Var) { super(n0Var); } @Override // h5.v, h5.n0 public void k0(h5.d dVar, long j10) { super.k0(dVar, j10); this.f11600b += j10; } } public b(boolean z10) { this.f11599a = z10; } @Override // h5.d0 public i0 a(d0.a aVar) { i0.a a02; l0 f10; g gVar = (g) aVar; c i10 = gVar.i(); k5.g k10 = gVar.k(); k5.c cVar = (k5.c) gVar.g(); h0 d10 = gVar.d(); long currentTimeMillis = System.currentTimeMillis(); gVar.h().o(gVar.f()); i10.d(d10); gVar.h().n(gVar.f(), d10); i0.a aVar2 = null; if (f.a(d10.f()) && d10.a() != null) { if ("100-continue".equalsIgnoreCase(d10.c("Expect"))) { i10.c(); gVar.h().s(gVar.f()); aVar2 = i10.b(true); } if (aVar2 == null) { gVar.h().m(gVar.f()); a aVar3 = new a(i10.e(d10, d10.a().a())); h5.e e10 = g0.e(aVar3); d10.a().e(e10); e10.close(); gVar.h().l(gVar.f(), aVar3.f11600b); } else if (!cVar.o()) { k10.l(); } } i10.a(); if (aVar2 == null) { gVar.h().s(gVar.f()); aVar2 = i10.b(false); } i0 e11 = aVar2.o(d10).h(k10.i().l()).p(currentTimeMillis).n(System.currentTimeMillis()).e(); int G = e11.G(); if (G == 100) { e11 = i10.b(false).o(d10).h(k10.i().l()).p(currentTimeMillis).n(System.currentTimeMillis()).e(); G = e11.G(); } gVar.h().r(gVar.f(), e11); if (this.f11599a && G == 101) { a02 = e11.a0(); f10 = i5.c.f10873c; } else { a02 = e11.a0(); f10 = i10.f(e11); } i0 e12 = a02.d(f10).e(); if ("close".equalsIgnoreCase(e12.j0().c("Connection")) || "close".equalsIgnoreCase(e12.O("Connection"))) { k10.l(); } if ((G != 204 && G != 205) || e12.c().z() <= 0) { return e12; } throw new ProtocolException("HTTP " + G + " had non-zero Content-Length: " + e12.c().z()); } }