package com.igaworks.ssp.common.o; import android.os.Handler; import android.os.Looper; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; /* loaded from: classes2.dex */ public class l extends Thread { /* renamed from: c, reason: collision with root package name */ private static Handler f6827c = new Handler(Looper.getMainLooper()); /* renamed from: a, reason: collision with root package name */ private final b f6828a; /* renamed from: b, reason: collision with root package name */ private String f6829b; class a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ String f6830a; a(String str) { this.f6830a = str; } @Override // java.lang.Runnable public void run() { try { if (this.f6830a != null) { l.this.f6828a.a(this.f6830a); } else { l.this.f6828a.a(); } } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); l.this.f6828a.a(); } } } public interface b { void a(); void a(String str); } public l(String str, b bVar) { this.f6829b = str; this.f6828a = bVar; } private void b(String str) { try { if (f6827c == null) { f6827c = new Handler(Looper.getMainLooper()); } f6827c.post(new a(str)); } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); this.f6828a.a(); } } /* JADX WARN: Code restructure failed: missing block: B:17:0x002a, code lost: com.igaworks.ssp.common.o.m.a.c(java.lang.Thread.currentThread(), "Redirect URL is not http(s) : " + r0); b(r0); */ @Override // java.lang.Thread, java.lang.Runnable /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public void run() { /* r8 = this; super.run() java.lang.String r0 = r8.f6829b boolean r0 = com.igaworks.ssp.common.o.k.b(r0) r1 = 0 if (r0 == 0) goto Lf r8.b(r1) Lf: java.lang.String r0 = r8.f6829b // Catch: java.lang.Throwable -> L6a r2 = 0 r3 = r1 L13: if (r0 == 0) goto L78 r4 = 10 if (r2 >= r4) goto L78 java.lang.String r4 = "http://" boolean r4 = r0.contains(r4) // Catch: java.lang.Throwable -> L68 if (r4 != 0) goto L46 java.lang.String r4 = "https://" boolean r4 = r0.contains(r4) // Catch: java.lang.Throwable -> L68 if (r4 == 0) goto L2a goto L46 L2a: java.lang.Thread r2 = java.lang.Thread.currentThread() // Catch: java.lang.Throwable -> L68 java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L68 r4.() // Catch: java.lang.Throwable -> L68 java.lang.String r5 = "Redirect URL is not http(s) : " r4.append(r5) // Catch: java.lang.Throwable -> L68 r4.append(r0) // Catch: java.lang.Throwable -> L68 java.lang.String r4 = r4.toString() // Catch: java.lang.Throwable -> L68 com.igaworks.ssp.common.o.m.a.c(r2, r4) // Catch: java.lang.Throwable -> L68 r8.b(r0) // Catch: java.lang.Throwable -> L68 goto L78 L46: java.lang.Thread r4 = java.lang.Thread.currentThread() // Catch: java.lang.Throwable -> L68 java.lang.StringBuilder r5 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L68 r5.() // Catch: java.lang.Throwable -> L68 java.lang.String r6 = "Redirect URL is : " r5.append(r6) // Catch: java.lang.Throwable -> L68 r5.append(r0) // Catch: java.lang.Throwable -> L68 java.lang.String r5 = r5.toString() // Catch: java.lang.Throwable -> L68 com.igaworks.ssp.common.o.m.a.c(r4, r5) // Catch: java.lang.Throwable -> L68 java.lang.String r3 = r8.a(r0) // Catch: java.lang.Throwable -> L6b int r2 = r2 + 1 r7 = r3 r3 = r0 r0 = r7 goto L13 L68: r0 = r3 goto L6b L6a: r0 = r1 L6b: java.lang.Thread r2 = java.lang.Thread.currentThread() java.lang.String r3 = "Exception occurred while resolving redirect URL" com.igaworks.ssp.common.o.m.a.b(r2, r3) r8.b(r1) r3 = r0 L78: r8.b(r3) return */ throw new UnsupportedOperationException("Method not decompiled: com.igaworks.ssp.common.o.l.run():void"); } private String a(String str) { HttpURLConnection httpURLConnection; HttpURLConnection httpURLConnection2 = null; try { httpURLConnection = (HttpURLConnection) new URL(str).openConnection(); } catch (Throwable th) { th = th; } try { httpURLConnection.setInstanceFollowRedirects(false); String a10 = a(str, httpURLConnection); try { InputStream inputStream = httpURLConnection.getInputStream(); if (inputStream != null) { inputStream.close(); } } catch (IOException unused) { com.igaworks.ssp.common.o.m.a.b(Thread.currentThread(), "IOException when closing httpUrlConnection. Ignoring."); } httpURLConnection.disconnect(); return a10; } catch (Throwable th2) { th = th2; httpURLConnection2 = httpURLConnection; if (httpURLConnection2 != null) { try { InputStream inputStream2 = httpURLConnection2.getInputStream(); if (inputStream2 != null) { inputStream2.close(); } } catch (IOException unused2) { com.igaworks.ssp.common.o.m.a.b(Thread.currentThread(), "IOException when closing httpUrlConnection. Ignoring."); } httpURLConnection2.disconnect(); } throw th; } } static String a(String str, HttpURLConnection httpURLConnection) { URI uri = new URI(str); int responseCode = httpURLConnection.getResponseCode(); String headerField = httpURLConnection.getHeaderField("Location"); if (responseCode < 300 || responseCode >= 400) { return null; } try { return uri.resolve(headerField).toString(); } catch (IllegalArgumentException unused) { com.igaworks.ssp.common.o.m.a.b(Thread.currentThread(), "Invalid URL redirection. baseUrl=" + str + "\n redirectUrl=" + headerField); throw new URISyntaxException(headerField, "Unable to parse invalid URL"); } catch (NullPointerException e10) { com.igaworks.ssp.common.o.m.a.b(Thread.currentThread(), "Invalid URL redirection. baseUrl=" + str + "\n redirectUrl=" + headerField); throw e10; } } }