540 lines
16 KiB
Java
540 lines
16 KiB
Java
|
package com.facetec.sdk;
|
||
|
|
||
|
import com.facetec.sdk.jv;
|
||
|
import com.facetec.sdk.kh;
|
||
|
import com.google.common.net.HttpHeaders;
|
||
|
import java.io.EOFException;
|
||
|
import java.io.IOException;
|
||
|
import java.net.ProtocolException;
|
||
|
import java.net.Proxy;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class lp implements lh {
|
||
|
final mv a;
|
||
|
final mr b;
|
||
|
final ka c;
|
||
|
final ky d;
|
||
|
int e = 0;
|
||
|
private long f = 262144;
|
||
|
|
||
|
public lp(ka kaVar, ky kyVar, mr mrVar, mv mvVar) {
|
||
|
this.c = kaVar;
|
||
|
this.d = kyVar;
|
||
|
this.b = mrVar;
|
||
|
this.a = mvVar;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lh
|
||
|
public final nj b(ke keVar, long j) {
|
||
|
if ("chunked".equalsIgnoreCase(keVar.c(HttpHeaders.TRANSFER_ENCODING))) {
|
||
|
if (this.e != 1) {
|
||
|
StringBuilder sb = new StringBuilder("state: ");
|
||
|
sb.append(this.e);
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
this.e = 2;
|
||
|
return new e(this);
|
||
|
}
|
||
|
if (j == -1) {
|
||
|
throw new IllegalStateException("Cannot stream a request body without chunked encoding or a known content length!");
|
||
|
}
|
||
|
if (this.e != 1) {
|
||
|
StringBuilder sb2 = new StringBuilder("state: ");
|
||
|
sb2.append(this.e);
|
||
|
throw new IllegalStateException(sb2.toString());
|
||
|
}
|
||
|
this.e = 2;
|
||
|
return new b(this, j);
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lh
|
||
|
public final void b() {
|
||
|
kt e2 = this.d.e();
|
||
|
if (e2 != null) {
|
||
|
e2.a();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lh
|
||
|
public final void b(ke keVar) throws IOException {
|
||
|
Proxy.Type type = this.d.e().c().b().type();
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(keVar.c());
|
||
|
sb.append(' ');
|
||
|
if (lk.e(keVar, type)) {
|
||
|
sb.append(keVar.a());
|
||
|
} else {
|
||
|
sb.append(lk.e(keVar.a()));
|
||
|
}
|
||
|
sb.append(" HTTP/1.1");
|
||
|
b(keVar.b(), sb.toString());
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lh
|
||
|
public final kf b(kh khVar) throws IOException {
|
||
|
jx jxVar = this.d.a;
|
||
|
jo joVar = this.d.d;
|
||
|
String b2 = khVar.b(HttpHeaders.CONTENT_TYPE);
|
||
|
if (!le.d(khVar)) {
|
||
|
return new lj(b2, 0L, nb.c(a(0L)));
|
||
|
}
|
||
|
if ("chunked".equalsIgnoreCase(khVar.b(HttpHeaders.TRANSFER_ENCODING))) {
|
||
|
kc a2 = khVar.a().a();
|
||
|
if (this.e == 4) {
|
||
|
this.e = 5;
|
||
|
return new lj(b2, -1L, nb.c(new c(this, a2)));
|
||
|
}
|
||
|
StringBuilder sb = new StringBuilder("state: ");
|
||
|
sb.append(this.e);
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
long b3 = le.b(khVar);
|
||
|
if (b3 != -1) {
|
||
|
return new lj(b2, b3, nb.c(a(b3)));
|
||
|
}
|
||
|
if (this.e != 4) {
|
||
|
StringBuilder sb2 = new StringBuilder("state: ");
|
||
|
sb2.append(this.e);
|
||
|
throw new IllegalStateException(sb2.toString());
|
||
|
}
|
||
|
ky kyVar = this.d;
|
||
|
if (kyVar == null) {
|
||
|
throw new IllegalStateException("streamAllocation == null");
|
||
|
}
|
||
|
this.e = 5;
|
||
|
kyVar.b();
|
||
|
return new lj(b2, -1L, nb.c(new i(this)));
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lh
|
||
|
public final void c() throws IOException {
|
||
|
this.a.flush();
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lh
|
||
|
public final void d() throws IOException {
|
||
|
this.a.flush();
|
||
|
}
|
||
|
|
||
|
public final void b(jv jvVar, String str) throws IOException {
|
||
|
if (this.e != 0) {
|
||
|
StringBuilder sb = new StringBuilder("state: ");
|
||
|
sb.append(this.e);
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
this.a.e(str).e("\r\n");
|
||
|
int c2 = jvVar.c();
|
||
|
for (int i2 = 0; i2 < c2; i2++) {
|
||
|
this.a.e(jvVar.c(i2)).e(": ").e(jvVar.a(i2)).e("\r\n");
|
||
|
}
|
||
|
this.a.e("\r\n");
|
||
|
this.e = 1;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lh
|
||
|
public final kh.d c(boolean z) throws IOException {
|
||
|
int i2 = this.e;
|
||
|
if (i2 != 1 && i2 != 3) {
|
||
|
StringBuilder sb = new StringBuilder("state: ");
|
||
|
sb.append(this.e);
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
try {
|
||
|
lm e2 = lm.e(e());
|
||
|
kh.d b2 = new kh.d().e(e2.b).c(e2.c).b(e2.d).b(a());
|
||
|
if (z && e2.c == 100) {
|
||
|
return null;
|
||
|
}
|
||
|
if (e2.c == 100) {
|
||
|
this.e = 3;
|
||
|
return b2;
|
||
|
}
|
||
|
this.e = 4;
|
||
|
return b2;
|
||
|
} catch (EOFException e3) {
|
||
|
StringBuilder sb2 = new StringBuilder("unexpected end of stream on ");
|
||
|
sb2.append(this.d);
|
||
|
IOException iOException = new IOException(sb2.toString());
|
||
|
iOException.initCause(e3);
|
||
|
throw iOException;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private String e() throws IOException {
|
||
|
String a2 = this.b.a(this.f);
|
||
|
this.f -= a2.length();
|
||
|
return a2;
|
||
|
}
|
||
|
|
||
|
public final jv a() throws IOException {
|
||
|
jv.a aVar = new jv.a();
|
||
|
while (true) {
|
||
|
String e2 = e();
|
||
|
if (e2.length() != 0) {
|
||
|
kn.a.a(aVar, e2);
|
||
|
} else {
|
||
|
return aVar.e();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final nk a(long j) throws IOException {
|
||
|
if (this.e != 4) {
|
||
|
StringBuilder sb = new StringBuilder("state: ");
|
||
|
sb.append(this.e);
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
this.e = 5;
|
||
|
return new a(this, j);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
final class b implements nj {
|
||
|
private long a;
|
||
|
private boolean b;
|
||
|
private final mw c;
|
||
|
private lp e;
|
||
|
|
||
|
b(lp lpVar, long j) {
|
||
|
this.e = lpVar;
|
||
|
this.c = new mw(this.e.a.b());
|
||
|
this.a = j;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj
|
||
|
public final void c(ms msVar, long j) throws IOException {
|
||
|
if (this.b) {
|
||
|
throw new IllegalStateException("closed");
|
||
|
}
|
||
|
km.e(msVar.c(), j);
|
||
|
if (j > this.a) {
|
||
|
StringBuilder sb = new StringBuilder("expected ");
|
||
|
sb.append(this.a);
|
||
|
sb.append(" bytes but received ");
|
||
|
sb.append(j);
|
||
|
throw new ProtocolException(sb.toString());
|
||
|
}
|
||
|
this.e.a.c(msVar, j);
|
||
|
this.a -= j;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj, java.io.Flushable
|
||
|
public final void flush() throws IOException {
|
||
|
if (this.b) {
|
||
|
return;
|
||
|
}
|
||
|
this.e.a.flush();
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
if (this.b) {
|
||
|
return;
|
||
|
}
|
||
|
this.b = true;
|
||
|
if (this.a > 0) {
|
||
|
throw new ProtocolException("unexpected end of stream");
|
||
|
}
|
||
|
lp.c(this.c);
|
||
|
this.e.e = 3;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj
|
||
|
public final nh b() {
|
||
|
return this.c;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
final class e implements nj {
|
||
|
private lp a;
|
||
|
private boolean b;
|
||
|
private final mw c;
|
||
|
|
||
|
e(lp lpVar) {
|
||
|
this.a = lpVar;
|
||
|
this.c = new mw(this.a.a.b());
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj
|
||
|
public final void c(ms msVar, long j) throws IOException {
|
||
|
if (this.b) {
|
||
|
throw new IllegalStateException("closed");
|
||
|
}
|
||
|
if (j == 0) {
|
||
|
return;
|
||
|
}
|
||
|
this.a.a.h(j);
|
||
|
this.a.a.e("\r\n");
|
||
|
this.a.a.c(msVar, j);
|
||
|
this.a.a.e("\r\n");
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj, java.io.Flushable
|
||
|
public final void flush() throws IOException {
|
||
|
synchronized (this) {
|
||
|
if (this.b) {
|
||
|
return;
|
||
|
}
|
||
|
this.a.a.flush();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
synchronized (this) {
|
||
|
if (this.b) {
|
||
|
return;
|
||
|
}
|
||
|
this.b = true;
|
||
|
this.a.a.e("0\r\n\r\n");
|
||
|
lp.c(this.c);
|
||
|
this.a.e = 3;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nj
|
||
|
public final nh b() {
|
||
|
return this.c;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
abstract class d implements nk {
|
||
|
private long a;
|
||
|
private lp b;
|
||
|
private mw c;
|
||
|
protected boolean d;
|
||
|
|
||
|
private d(lp lpVar) {
|
||
|
this.b = lpVar;
|
||
|
this.c = new mw(this.b.b.b());
|
||
|
this.a = 0L;
|
||
|
}
|
||
|
|
||
|
/* synthetic */ d(lp lpVar, byte b) {
|
||
|
this(lpVar);
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nk
|
||
|
public long b(ms msVar, long j) throws IOException {
|
||
|
try {
|
||
|
long b = this.b.b.b(msVar, j);
|
||
|
if (b > 0) {
|
||
|
this.a += b;
|
||
|
}
|
||
|
return b;
|
||
|
} catch (IOException e) {
|
||
|
d(false, e);
|
||
|
throw e;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected final void d(boolean z, IOException iOException) throws IOException {
|
||
|
if (this.b.e == 6) {
|
||
|
return;
|
||
|
}
|
||
|
if (this.b.e != 5) {
|
||
|
StringBuilder sb = new StringBuilder("state: ");
|
||
|
sb.append(this.b.e);
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
lp.c(this.c);
|
||
|
this.b.e = 6;
|
||
|
if (this.b.d != null) {
|
||
|
this.b.d.e(!z, this.b, iOException);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nk
|
||
|
public final nh b() {
|
||
|
return this.c;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class a extends d {
|
||
|
private long a;
|
||
|
private lp e;
|
||
|
|
||
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||
|
a(lp lpVar, long j) throws IOException {
|
||
|
super(lpVar, (byte) 0);
|
||
|
this.e = lpVar;
|
||
|
this.a = j;
|
||
|
if (j == 0) {
|
||
|
d(true, null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lp.d, com.facetec.sdk.nk
|
||
|
public final long b(ms msVar, long j) throws IOException {
|
||
|
if (j < 0) {
|
||
|
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)));
|
||
|
}
|
||
|
if (this.d) {
|
||
|
throw new IllegalStateException("closed");
|
||
|
}
|
||
|
long j2 = this.a;
|
||
|
if (j2 == 0) {
|
||
|
return -1L;
|
||
|
}
|
||
|
long b = super.b(msVar, Math.min(j2, j));
|
||
|
if (b == -1) {
|
||
|
ProtocolException protocolException = new ProtocolException("unexpected end of stream");
|
||
|
d(false, protocolException);
|
||
|
throw protocolException;
|
||
|
}
|
||
|
long j3 = this.a - b;
|
||
|
this.a = j3;
|
||
|
if (j3 == 0) {
|
||
|
d(true, null);
|
||
|
}
|
||
|
return b;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
if (this.d) {
|
||
|
return;
|
||
|
}
|
||
|
if (this.a != 0 && !km.e(this, TimeUnit.MILLISECONDS)) {
|
||
|
d(false, null);
|
||
|
}
|
||
|
this.d = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
final class c extends d {
|
||
|
private final kc a;
|
||
|
private lp b;
|
||
|
private long c;
|
||
|
private boolean e;
|
||
|
|
||
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||
|
c(lp lpVar, kc kcVar) {
|
||
|
super(lpVar, (byte) 0);
|
||
|
this.b = lpVar;
|
||
|
this.c = -1L;
|
||
|
this.e = true;
|
||
|
this.a = kcVar;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lp.d, com.facetec.sdk.nk
|
||
|
public final long b(ms msVar, long j) throws IOException {
|
||
|
if (j < 0) {
|
||
|
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)));
|
||
|
}
|
||
|
if (this.d) {
|
||
|
throw new IllegalStateException("closed");
|
||
|
}
|
||
|
if (!this.e) {
|
||
|
return -1L;
|
||
|
}
|
||
|
long j2 = this.c;
|
||
|
if (j2 == 0 || j2 == -1) {
|
||
|
if (j2 != -1) {
|
||
|
this.b.b.o();
|
||
|
}
|
||
|
try {
|
||
|
this.c = this.b.b.m();
|
||
|
String trim = this.b.b.o().trim();
|
||
|
if (this.c < 0 || !(trim.isEmpty() || trim.startsWith(";"))) {
|
||
|
StringBuilder sb = new StringBuilder("expected chunk size and optional extensions but was \"");
|
||
|
sb.append(this.c);
|
||
|
sb.append(trim);
|
||
|
sb.append("\"");
|
||
|
throw new ProtocolException(sb.toString());
|
||
|
}
|
||
|
if (this.c == 0) {
|
||
|
this.e = false;
|
||
|
le.c(this.b.c.a(), this.a, this.b.a());
|
||
|
d(true, null);
|
||
|
}
|
||
|
if (!this.e) {
|
||
|
return -1L;
|
||
|
}
|
||
|
} catch (NumberFormatException e) {
|
||
|
throw new ProtocolException(e.getMessage());
|
||
|
}
|
||
|
}
|
||
|
long b = super.b(msVar, Math.min(j, this.c));
|
||
|
if (b != -1) {
|
||
|
this.c -= b;
|
||
|
return b;
|
||
|
}
|
||
|
ProtocolException protocolException = new ProtocolException("unexpected end of stream");
|
||
|
d(false, protocolException);
|
||
|
throw protocolException;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
if (this.d) {
|
||
|
return;
|
||
|
}
|
||
|
if (this.e && !km.e(this, TimeUnit.MILLISECONDS)) {
|
||
|
d(false, null);
|
||
|
}
|
||
|
this.d = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
final class i extends d {
|
||
|
private boolean a;
|
||
|
private lp b;
|
||
|
|
||
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||
|
i(lp lpVar) {
|
||
|
super(lpVar, (byte) 0);
|
||
|
this.b = lpVar;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.lp.d, com.facetec.sdk.nk
|
||
|
public final long b(ms msVar, long j) throws IOException {
|
||
|
if (j < 0) {
|
||
|
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)));
|
||
|
}
|
||
|
if (this.d) {
|
||
|
throw new IllegalStateException("closed");
|
||
|
}
|
||
|
if (this.a) {
|
||
|
return -1L;
|
||
|
}
|
||
|
long b = super.b(msVar, j);
|
||
|
if (b != -1) {
|
||
|
return b;
|
||
|
}
|
||
|
this.a = true;
|
||
|
d(true, null);
|
||
|
return -1L;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
if (this.d) {
|
||
|
return;
|
||
|
}
|
||
|
if (!this.a) {
|
||
|
d(false, null);
|
||
|
}
|
||
|
this.d = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void c(mw mwVar) {
|
||
|
nh nhVar = mwVar.d;
|
||
|
nh nhVar2 = nh.c;
|
||
|
if (nhVar2 == null) {
|
||
|
throw new IllegalArgumentException("delegate == null");
|
||
|
}
|
||
|
mwVar.d = nhVar2;
|
||
|
nhVar.d_();
|
||
|
nhVar.e_();
|
||
|
}
|
||
|
}
|