what-the-bank/sources/com/google/android/gms/internal/firebase_ml/zzfk.java

161 lines
4.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.firebase_ml;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
/* loaded from: classes2.dex */
public final class zzfk {
private final int statusCode;
private final zzfg zztm;
private int zzuk;
private boolean zzul;
private InputStream zzux;
private final String zzuy;
private final String zzuz;
private zzfq zzva;
private final String zzvb;
private final zzfh zzvc;
private boolean zzvd;
/* JADX INFO: Access modifiers changed from: package-private */
public zzfk(zzfh zzfhVar, zzfq zzfqVar) throws IOException {
StringBuilder sb;
this.zzvc = zzfhVar;
this.zzuk = zzfhVar.zzfc();
this.zzul = zzfhVar.zzfd();
this.zzva = zzfqVar;
this.zzuy = zzfqVar.getContentEncoding();
int statusCode = zzfqVar.getStatusCode();
boolean z = false;
statusCode = statusCode < 0 ? 0 : statusCode;
this.statusCode = statusCode;
String reasonPhrase = zzfqVar.getReasonPhrase();
this.zzvb = reasonPhrase;
Logger logger = zzfo.zzve;
if (this.zzul && logger.isLoggable(Level.CONFIG)) {
z = true;
}
if (z) {
sb = new StringBuilder();
sb.append("-------------- RESPONSE --------------");
sb.append(zzhz.zzaae);
String zzfp = zzfqVar.zzfp();
if (zzfp != null) {
sb.append(zzfp);
} else {
sb.append(statusCode);
if (reasonPhrase != null) {
sb.append(' ');
sb.append(reasonPhrase);
}
}
sb.append(zzhz.zzaae);
} else {
sb = null;
}
zzfhVar.zzff().zza(zzfqVar, z ? sb : null);
String contentType = zzfqVar.getContentType();
contentType = contentType == null ? zzfhVar.zzff().getContentType() : contentType;
this.zzuz = contentType;
this.zztm = contentType != null ? new zzfg(contentType) : null;
if (z) {
logger.logp(Level.CONFIG, "o.vgU", "<init>", sb.toString());
}
}
public final zzfe zzfe() {
return this.zzvc.zzff();
}
public final InputStream getContent() throws IOException {
if (!this.zzvd) {
InputStream content = this.zzva.getContent();
if (content != null) {
try {
String str = this.zzuy;
if (str != null && str.contains("gzip")) {
content = new GZIPInputStream(content);
}
Logger logger = zzfo.zzve;
if (this.zzul && logger.isLoggable(Level.CONFIG)) {
content = new zzhq(content, logger, Level.CONFIG, this.zzuk);
}
this.zzux = content;
} catch (EOFException unused) {
content.close();
} catch (Throwable th) {
content.close();
throw th;
}
}
this.zzvd = true;
}
return this.zzux;
}
public final void ignore() throws IOException {
InputStream content = getContent();
if (content != null) {
content.close();
}
}
public final void disconnect() throws IOException {
ignore();
this.zzva.disconnect();
}
public final <T> T zza(Class<T> cls) throws IOException {
int i = this.statusCode;
if (this.zzvc.getRequestMethod().equals("HEAD") || i / 100 == 1 || i == 204 || i == 304) {
ignore();
return null;
}
return (T) this.zzvc.zzfh().zza(getContent(), zzfm(), cls);
}
public final String zzfl() throws IOException {
InputStream content = getContent();
if (content == null) {
return "";
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
zzhb.copy(content, byteArrayOutputStream);
content.close();
return byteArrayOutputStream.toString(zzfm().name());
} catch (Throwable th) {
content.close();
throw th;
}
}
private final Charset zzfm() {
zzfg zzfgVar = this.zztm;
return (zzfgVar == null || zzfgVar.zzey() == null) ? zzhc.ISO_8859_1 : this.zztm.zzey();
}
public final boolean zzfk() {
int i = this.statusCode;
return i >= 200 && i < 300;
}
public final String getStatusMessage() {
return this.zzvb;
}
public final int getStatusCode() {
return this.statusCode;
}
public final String getContentType() {
return this.zzuz;
}
}