2021-12-17 21:59:34 +00:00
package b.f.j.p ;
2021-07-24 02:37:17 +00:00
import android.net.Uri ;
2022-01-13 08:07:50 +00:00
import b.c.a.a0.d ;
2021-12-17 21:59:34 +00:00
import b.f.d.k.b ;
import b.f.j.j.e ;
2021-07-24 02:37:17 +00:00
import com.facebook.common.time.RealtimeSinceBootClock ;
import java.io.IOException ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.util.Locale ;
import java.util.concurrent.ExecutorService ;
import java.util.concurrent.Executors ;
2022-03-07 09:34:54 +00:00
/* compiled from: HttpUrlConnectionNetworkFetcher.java */
2022-04-04 09:20:14 +00:00
/* loaded from: classes3.dex */
2021-07-24 02:37:17 +00:00
public class a0 extends c < a > {
public int a ;
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-03-28 08:10:50 +00:00
public final ExecutorService f603b = Executors . newFixedThreadPool ( 3 ) ;
2021-12-17 21:59:34 +00:00
public final b c ;
2021-07-24 02:37:17 +00:00
2022-03-07 09:34:54 +00:00
/* compiled from: HttpUrlConnectionNetworkFetcher.java */
2022-04-04 09:20:14 +00:00
/* loaded from: classes3.dex */
2021-07-24 02:37:17 +00:00
public static class a extends x {
public long d ;
public long e ;
public long f ;
2022-01-13 08:07:50 +00:00
public a ( l < e > lVar , x0 x0Var ) {
super ( lVar , x0Var ) ;
2021-07-24 02:37:17 +00:00
}
}
public a0 ( int i ) {
RealtimeSinceBootClock realtimeSinceBootClock = RealtimeSinceBootClock . get ( ) ;
2021-12-17 21:59:34 +00:00
this . c = realtimeSinceBootClock ;
2021-07-24 02:37:17 +00:00
this . a = i ;
}
2022-03-07 09:34:54 +00:00
/* JADX WARN: Removed duplicated region for block: B:23:0x0040 */
/* JADX WARN: Removed duplicated region for block: B:38:0x009b */
/ *
Code decompiled incorrectly , please refer to instructions dump .
* /
2021-07-24 02:37:17 +00:00
public final HttpURLConnection a ( Uri uri , int i ) throws IOException {
URL url ;
boolean z2 ;
2021-12-17 21:59:34 +00:00
Uri uri2 = b . f . d . l . b . a ;
2021-07-24 02:37:17 +00:00
Uri uri3 = null ;
if ( uri = = null ) {
url = null ;
} else {
try {
url = new URL ( uri . toString ( ) ) ;
} catch ( MalformedURLException e ) {
throw new RuntimeException ( e ) ;
}
}
HttpURLConnection httpURLConnection = ( HttpURLConnection ) url . openConnection ( ) ;
httpURLConnection . setConnectTimeout ( this . a ) ;
int responseCode = httpURLConnection . getResponseCode ( ) ;
if ( responseCode > = 200 & & responseCode < 300 ) {
return httpURLConnection ;
}
if ( ! ( responseCode = = 307 | | responseCode = = 308 ) ) {
switch ( responseCode ) {
case 300 :
case 301 :
case 302 :
case 303 :
break ;
default :
z2 = false ;
break ;
}
if ( ! z2 ) {
String headerField = httpURLConnection . getHeaderField ( " Location " ) ;
httpURLConnection . disconnect ( ) ;
if ( headerField ! = null ) {
uri3 = Uri . parse ( headerField ) ;
}
String scheme = uri . getScheme ( ) ;
2022-01-13 08:07:50 +00:00
if ( i > 0 & & uri3 ! = null & & ! d . g0 ( uri3 . getScheme ( ) , scheme ) ) {
2021-07-24 02:37:17 +00:00
return a ( uri3 , i - 1 ) ;
}
throw new IOException ( i = = 0 ? String . format ( Locale . getDefault ( ) , " URL %s follows too many redirects " , uri . toString ( ) ) : String . format ( Locale . getDefault ( ) , " URL %s returned %d without a valid redirect " , uri . toString ( ) , Integer . valueOf ( responseCode ) ) ) ;
}
httpURLConnection . disconnect ( ) ;
throw new IOException ( String . format ( " Image URL %s returned HTTP code %d " , uri . toString ( ) , Integer . valueOf ( responseCode ) ) ) ;
}
z2 = true ;
if ( ! z2 ) {
}
}
}