package com.facetec.sdk; import com.facetec.sdk.kb; import com.facetec.sdk.ke; import com.facetec.sdk.kh; import com.google.common.net.HttpHeaders; import java.io.IOException; import java.util.List; /* loaded from: classes.dex */ public final class lc implements kb { private final js a; public lc(js jsVar) { this.a = jsVar; } @Override // com.facetec.sdk.kb public final kh a(kb.c cVar) throws IOException { boolean z; ke b = cVar.b(); ke.d d = b.d(); ki e = b.e(); if (e != null) { jz b2 = e.b(); if (b2 != null) { d.a(HttpHeaders.CONTENT_TYPE, b2.toString()); } long a = e.a(); if (a != -1) { d.a(HttpHeaders.CONTENT_LENGTH, Long.toString(a)); d.e(HttpHeaders.TRANSFER_ENCODING); } else { d.a(HttpHeaders.TRANSFER_ENCODING, "chunked"); d.e(HttpHeaders.CONTENT_LENGTH); } } if (b.c(HttpHeaders.HOST) == null) { d.a(HttpHeaders.HOST, km.b(b.a(), false)); } if (b.c(HttpHeaders.CONNECTION) == null) { d.a(HttpHeaders.CONNECTION, "Keep-Alive"); } if (b.c(HttpHeaders.ACCEPT_ENCODING) == null && b.c(HttpHeaders.RANGE) == null) { d.a(HttpHeaders.ACCEPT_ENCODING, "gzip"); z = true; } else { z = false; } js jsVar = this.a; b.a(); List c = jsVar.c(); if (!c.isEmpty()) { StringBuilder sb = new StringBuilder(); int size = c.size(); for (int i = 0; i < size; i++) { if (i > 0) { sb.append("; "); } jq jqVar = c.get(i); sb.append(jqVar.a); sb.append('='); sb.append(jqVar.c); } d.a(HttpHeaders.COOKIE, sb.toString()); } if (b.c("User-Agent") == null) { d.a("User-Agent", kp.e()); } kh c2 = cVar.c(d.b()); le.c(this.a, b.a(), c2.d()); kh.d a2 = c2.g().a(b); if (z && "gzip".equalsIgnoreCase(c2.b(HttpHeaders.CONTENT_ENCODING)) && le.d(c2)) { na naVar = new na(c2.b().d()); a2.b(c2.d().e().b(HttpHeaders.CONTENT_ENCODING).b(HttpHeaders.CONTENT_LENGTH).e()); a2.b(new lj(c2.b(HttpHeaders.CONTENT_TYPE), -1L, nb.c(naVar))); } return a2.d(); } }