package com.facetec.sdk; import com.facetec.sdk.kb; import com.facetec.sdk.kh; import com.google.common.net.HttpHeaders; import java.io.IOException; import java.net.ProtocolException; /* loaded from: classes.dex */ public final class la implements kb { private final boolean a; public la(boolean z) { this.a = z; } @Override // com.facetec.sdk.kb public final kh a(kb.c cVar) throws IOException { kh d; lf lfVar = (lf) cVar; lh lhVar = lfVar.c; ky d2 = lfVar.d(); kt ktVar = lfVar.d; ke b = lfVar.b(); long currentTimeMillis = System.currentTimeMillis(); lfVar.i(); lfVar.j(); lhVar.b(b); lfVar.i(); lfVar.j(); kh.d dVar = null; if (lg.a(b.c()) && b.e() != null) { if ("100-continue".equalsIgnoreCase(b.c(HttpHeaders.EXPECT))) { lhVar.c(); lfVar.i(); lfVar.j(); dVar = lhVar.c(true); } if (dVar == null) { lfVar.i(); lfVar.j(); a aVar = new a(lhVar.b(b, b.e().a())); mv e = nb.e(aVar); b.e().d(e); e.close(); lfVar.i(); lfVar.j(); long j = aVar.d; } else if (!ktVar.b()) { d2.b(); } } lhVar.d(); if (dVar == null) { lfVar.i(); lfVar.j(); dVar = lhVar.c(false); } kh d3 = dVar.a(b).a(d2.e().e()).b(currentTimeMillis).e(System.currentTimeMillis()).d(); int e2 = d3.e(); if (e2 == 100) { d3 = lhVar.c(false).a(b).a(d2.e().e()).b(currentTimeMillis).e(System.currentTimeMillis()).d(); e2 = d3.e(); } lfVar.i(); lfVar.j(); if (this.a && e2 == 101) { d = d3.g().b(km.d).d(); } else { d = d3.g().b(lhVar.b(d3)).d(); } if ("close".equalsIgnoreCase(d.a().c(HttpHeaders.CONNECTION)) || "close".equalsIgnoreCase(d.b(HttpHeaders.CONNECTION))) { d2.b(); } if ((e2 != 204 && e2 != 205) || d.b().e() <= 0) { return d; } StringBuilder sb = new StringBuilder("HTTP "); sb.append(e2); sb.append(" had non-zero Content-Length: "); sb.append(d.b().e()); throw new ProtocolException(sb.toString()); } /* loaded from: classes.dex */ static final class a extends mz { long d; a(nj njVar) { super(njVar); } @Override // com.facetec.sdk.mz, com.facetec.sdk.nj public final void c(ms msVar, long j) throws IOException { super.c(msVar, j); this.d += j; } } }