package com.google.android.gms.internal.firebase_ml; import com.google.android.gms.internal.firebase_ml.zzhm; import com.google.common.net.HttpHeaders; import java.io.IOException; import java.io.Writer; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; /* loaded from: classes2.dex */ public final class zzfe extends zzhm { @zzho("Accept") private List accept; @zzho(HttpHeaders.ACCEPT_ENCODING) private List acceptEncoding; @zzho(HttpHeaders.AGE) private List age; @zzho(HttpHeaders.WWW_AUTHENTICATE) private List authenticate; @zzho(HttpHeaders.AUTHORIZATION) private List authorization; @zzho(HttpHeaders.CACHE_CONTROL) private List cacheControl; @zzho(HttpHeaders.CONTENT_ENCODING) private List contentEncoding; @zzho(HttpHeaders.CONTENT_LENGTH) private List contentLength; @zzho(HttpHeaders.CONTENT_MD5) private List contentMD5; @zzho(HttpHeaders.CONTENT_RANGE) private List contentRange; @zzho(HttpHeaders.CONTENT_TYPE) private List contentType; @zzho(HttpHeaders.COOKIE) private List cookie; @zzho(HttpHeaders.DATE) private List date; @zzho(HttpHeaders.ETAG) private List etag; @zzho(HttpHeaders.EXPIRES) private List expires; @zzho(HttpHeaders.IF_MATCH) private List ifMatch; @zzho(HttpHeaders.IF_MODIFIED_SINCE) private List ifModifiedSince; @zzho(HttpHeaders.IF_NONE_MATCH) private List ifNoneMatch; @zzho(HttpHeaders.IF_RANGE) private List ifRange; @zzho(HttpHeaders.IF_UNMODIFIED_SINCE) private List ifUnmodifiedSince; @zzho(HttpHeaders.LAST_MODIFIED) private List lastModified; @zzho(HttpHeaders.LOCATION) private List location; @zzho("MIME-Version") private List mimeVersion; @zzho(HttpHeaders.RANGE) private List range; @zzho(HttpHeaders.RETRY_AFTER) private List retryAfter; @zzho("User-Agent") private List userAgent; public zzfe() { super(EnumSet.of(zzhm.zzc.IGNORE_CASE)); this.acceptEncoding = new ArrayList(Collections.singleton("gzip")); } public final zzfe zzy(String str) { this.authorization = zza((Object) null); return this; } public final String getContentType() { return (String) zza((List) this.contentType); } public final zzfe zzz(String str) { this.ifModifiedSince = zza((Object) null); return this; } public final zzfe zzaa(String str) { this.ifMatch = zza((Object) null); return this; } public final zzfe zzab(String str) { this.ifNoneMatch = zza((Object) null); return this; } public final zzfe zzac(String str) { this.ifUnmodifiedSince = zza((Object) null); return this; } public final zzfe zzad(String str) { this.ifRange = zza((Object) null); return this; } public final String getLocation() { return (String) zza((List) this.location); } public final String zzex() { return (String) zza((List) this.userAgent); } public final zzfe zzae(String str) { this.userAgent = zza(str); return this; } private static void zza(Logger logger, StringBuilder sb, StringBuilder sb2, zzfp zzfpVar, String str, Object obj, Writer writer) throws IOException { if (obj == null || zzhf.isNull(obj)) { return; } String name = obj instanceof Enum ? zzhl.zza((Enum) obj).getName() : obj.toString(); String str2 = ((HttpHeaders.AUTHORIZATION.equalsIgnoreCase(str) || HttpHeaders.COOKIE.equalsIgnoreCase(str)) && (logger == null || !logger.isLoggable(Level.ALL))) ? "" : name; if (sb != null) { sb.append(str); sb.append(": "); sb.append(str2); sb.append(zzhz.zzaae); } if (sb2 != null) { sb2.append(" -H '"); sb2.append(str); sb2.append(": "); sb2.append(str2); sb2.append("'"); } if (zzfpVar != null) { zzfpVar.addHeader(str, name); } if (writer != null) { writer.write(str); writer.write(": "); writer.write(name); writer.write("\r\n"); } } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(zzfe zzfeVar, StringBuilder sb, StringBuilder sb2, Logger logger, zzfp zzfpVar) throws IOException { HashSet hashSet = new HashSet(); for (Map.Entry entry : zzfeVar.entrySet()) { String key = entry.getKey(); Object[] objArr = {key}; if (!hashSet.add(key)) { throw new IllegalArgumentException(zzla.zzb("multiple headers of the same name (headers are case insensitive): %s", objArr)); } Object value = entry.getValue(); if (value != null) { zzhl zzao = zzfeVar.zzhi().zzao(key); if (zzao != null) { key = zzao.getName(); } Class cls = value.getClass(); if ((value instanceof Iterable) || cls.isArray()) { Iterator it = zzia.zzi(value).iterator(); while (it.hasNext()) { zza(logger, sb, sb2, zzfpVar, key, it.next(), null); } } else { zza(logger, sb, sb2, zzfpVar, key, value, null); } } } } public final void zza(zzfq zzfqVar, StringBuilder sb) throws IOException { clear(); zzff zzffVar = new zzff(this, sb); int zzfq = zzfqVar.zzfq(); for (int i = 0; i < zzfq; i++) { String zzab = zzfqVar.zzab(i); String zzac = zzfqVar.zzac(i); List list = zzffVar.zzty; zzhd zzhdVar = zzffVar.zztx; zzgy zzgyVar = zzffVar.zztv; StringBuilder sb2 = zzffVar.zztw; if (sb2 != null) { StringBuilder sb3 = new StringBuilder(String.valueOf(zzab).length() + 2 + String.valueOf(zzac).length()); sb3.append(zzab); sb3.append(": "); sb3.append(zzac); sb2.append(sb3.toString()); sb2.append(zzhz.zzaae); } zzhl zzao = zzhdVar.zzao(zzab); if (zzao != null) { Type zza = zzhf.zza(list, zzao.getGenericType()); if (zzia.zzc(zza)) { Class zzb = zzia.zzb(list, zzia.zzd(zza)); zzgyVar.zza(zzao.zzhf(), zzb, zza(zzb, list, zzac)); } else if (zzia.zza(zzia.zzb(list, zza), (Class) Iterable.class)) { Collection collection = (Collection) zzao.zzh(this); if (collection == null) { collection = zzhf.zzb(zza); zzao.zzb(this, collection); } collection.add(zza(zza == Object.class ? null : zzia.zze(zza), list, zzac)); } else { zzao.zzb(this, zza(zza, list, zzac)); } } else { ArrayList arrayList = (ArrayList) get(zzab); if (arrayList == null) { arrayList = new ArrayList(); zzb(zzab, arrayList); } arrayList.add(zzac); } } zzffVar.zztv.zzha(); } private static T zza(List list) { if (list == null) { return null; } return list.get(0); } private static List zza(T t) { if (t == null) { return null; } ArrayList arrayList = new ArrayList(); arrayList.add(t); return arrayList; } private static Object zza(Type type, List list, String str) { return zzhf.zza(zzhf.zza(list, type), str); } @Override // com.google.android.gms.internal.firebase_ml.zzhm /* renamed from: zzeh */ public final /* synthetic */ zzhm clone() { return (zzfe) clone(); } @Override // com.google.android.gms.internal.firebase_ml.zzhm public final /* synthetic */ zzhm zzb(String str, Object obj) { return (zzfe) super.zzb(str, obj); } @Override // com.google.android.gms.internal.firebase_ml.zzhm, java.util.AbstractMap public final /* synthetic */ Object clone() throws CloneNotSupportedException { return (zzfe) super.clone(); } }