package com.google.android.gms.measurement.internal; import androidx.annotation.WorkerThread; import com.google.android.gms.common.internal.Preconditions; import com.mbridge.msdk.newreward.function.common.MBridgeCommon; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.util.List; import java.util.Map; @WorkerThread /* loaded from: classes3.dex */ final class zzkp implements Runnable { private final URL zza; private final zzkm zzb; private final String zzc; private final Map zzd; private final /* synthetic */ zzkn zze; public zzkp(zzkn zzknVar, String str, URL url, byte[] bArr, Map map, zzkm zzkmVar) { this.zze = zzknVar; Preconditions.checkNotEmpty(str); Preconditions.checkNotNull(url); Preconditions.checkNotNull(zzkmVar); this.zza = url; this.zzb = zzkmVar; this.zzc = str; this.zzd = null; } private final void zzb(final int i, final Exception exc, final byte[] bArr, final Map> map) { this.zze.zzl().zzb(new Runnable() { // from class: com.google.android.gms.measurement.internal.zzko @Override // java.lang.Runnable public final void run() { zzkp.this.zza(i, exc, bArr, map); } }); } public final /* synthetic */ void zza(int i, Exception exc, byte[] bArr, Map map) { this.zzb.zza(this.zzc, i, exc, bArr, map); } @Override // java.lang.Runnable public final void run() { HttpURLConnection httpURLConnection; Map> map; byte[] zza; this.zze.zzr(); int i = 0; try { URLConnection zza2 = com.google.android.gms.internal.measurement.zzcn.zza().zza(this.zza, "client-measurement"); if (!(zza2 instanceof HttpURLConnection)) { throw new IOException("Failed to obtain HTTP connection"); } httpURLConnection = (HttpURLConnection) zza2; httpURLConnection.setDefaultUseCaches(false); httpURLConnection.setConnectTimeout(MBridgeCommon.DEFAULT_LOAD_TIMEOUT); httpURLConnection.setReadTimeout(61000); httpURLConnection.setInstanceFollowRedirects(false); httpURLConnection.setDoInput(true); try { i = httpURLConnection.getResponseCode(); map = httpURLConnection.getHeaderFields(); try { zzkn zzknVar = this.zze; zza = zzkn.zza(httpURLConnection); httpURLConnection.disconnect(); zzb(i, null, zza, map); } catch (IOException e) { e = e; if (httpURLConnection != null) { httpURLConnection.disconnect(); } zzb(i, e, null, map); } catch (Throwable th) { th = th; if (httpURLConnection != null) { httpURLConnection.disconnect(); } zzb(i, null, null, map); throw th; } } catch (IOException e2) { e = e2; map = null; } catch (Throwable th2) { th = th2; map = null; } } catch (IOException e3) { e = e3; httpURLConnection = null; map = null; } catch (Throwable th3) { th = th3; httpURLConnection = null; map = null; } } }