package com.fyber.inneractive.sdk.network; import android.text.TextUtils; import android.util.Pair; import com.fyber.inneractive.sdk.util.IAlog; import java.io.BufferedInputStream; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.zip.GZIPInputStream; import okhttp3.Headers; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; /* loaded from: classes2.dex */ public final class w0 extends h implements g { public final OkHttpClient a = new OkHttpClient().newBuilder().build(); public static class a extends j { public final Response g; public a(j jVar, Response response) { this.g = response; a(jVar.d()); a(jVar.b()); a(jVar.c()); a(jVar.e()); } @Override // com.fyber.inneractive.sdk.network.j public final void a() throws IOException { super.a(); Response response = this.g; if (response != null) { response.close(); } } } public static HashMap b(Response response) { HashMap hashMap = new HashMap(); if (response != null) { Headers headers = response.headers(); for (int i = 0; i < headers.size(); i++) { String name = headers.name(i); hashMap.put(name, Collections.singletonList(headers.get(name))); } } return hashMap; } @Override // com.fyber.inneractive.sdk.network.g public final j a(c0 c0Var, String str, String str2) throws Exception { IAlog.a("%s okhttp network stack is in use", "OkHttpExecutorImpl"); try { ArrayList arrayList = new ArrayList(); arrayList.add(c0Var.getUrl()); Pair a2 = a(c0Var.getUrl(), c0Var, arrayList, str, str2); Object obj = a2.second; String message = obj != null ? ((Response) obj).message() : ""; FilterInputStream a3 = a((Response) a2.second); Object obj2 = a2.second; int code = obj2 == null ? -1 : ((Response) obj2).code(); HashMap b = b((Response) a2.second); Response response = (Response) a2.second; a aVar = new a(h.a(a3, code, message, b, response != null ? response.headers().get("Last-Modified") : null), (Response) a2.second); Iterator it = ((List) a2.first).iterator(); while (it.hasNext()) { aVar.f.add((String) it.next()); } return aVar; } catch (b e) { IAlog.b("%s cannot connect exception: %s", "OkHttpExecutorImpl", e.getMessage()); throw e; } catch (Exception e2) { IAlog.b("%s exception: %s", "OkHttpExecutorImpl", e2.getMessage()); throw e2; } } @Override // com.fyber.inneractive.sdk.network.g public final void a() { } /* JADX WARN: Code restructure failed: missing block: B:46:0x00dd, code lost: if (r8.code() != 308) goto L51; */ /* JADX WARN: Removed duplicated region for block: B:24:0x00e9 A[Catch: all -> 0x00c9, Exception -> 0x00cc, TryCatch #0 {Exception -> 0x00cc, blocks: (B:15:0x00aa, B:17:0x00b8, B:19:0x00c0, B:22:0x00df, B:24:0x00e9, B:26:0x00f1, B:28:0x00f9, B:30:0x00ff, B:33:0x011c, B:35:0x0133, B:37:0x013e, B:41:0x015a, B:42:0x0161, B:43:0x00cf, B:45:0x00d7, B:47:0x0162), top: B:14:0x00aa, outer: #1 }] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final android.util.Pair a(java.lang.String r8, com.fyber.inneractive.sdk.network.c0 r9, java.util.ArrayList r10, java.lang.String r11, java.lang.String r12) throws java.lang.Exception { /* Method dump skipped, instructions count: 411 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.fyber.inneractive.sdk.network.w0.a(java.lang.String, com.fyber.inneractive.sdk.network.c0, java.util.ArrayList, java.lang.String, java.lang.String):android.util.Pair"); } public static FilterInputStream a(Response response) { FilterInputStream bufferedInputStream; if (response == null) { return null; } try { if (response.body() == null) { return null; } boolean equals = TextUtils.equals("gzip", response.headers().get("content-encoding")); InputStream byteStream = response.body().byteStream(); if (equals) { IAlog.a("HttpExecutorBase: getInputStream found gzip encoding", new Object[0]); bufferedInputStream = new GZIPInputStream(byteStream); } else { IAlog.a("HttpExecutorBase: getInputStream no gzip encoding", new Object[0]); bufferedInputStream = new BufferedInputStream(byteStream); } return bufferedInputStream; } catch (Exception unused) { return null; } } public static void a(Request.Builder builder, String str, String str2) { if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) { return; } builder.addHeader(str, str2); } }