.class public final Lz5/g91;
.super Ljava/lang/Object;
.source ""

# interfaces
.implements Ljava/io/Closeable;


# instance fields
.field public r:Lz5/u91;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lz5/u91<",
            "Ljava/lang/Integer;",
            ">;"
        }
    .end annotation
.end field

.field public s:Lz5/u30;

.field public t:Ljava/net/HttpURLConnection;


# direct methods
.method public constructor <init>()V
    .registers 2

    sget-object v0, Lz5/f91;->r:Lz5/u91;

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 2
    iput-object v0, p0, Lz5/g91;->r:Lz5/u91;

    const/4 v0, 0x0

    iput-object v0, p0, Lz5/g91;->s:Lz5/u30;

    return-void
.end method


# virtual methods
.method public final b(Lz5/u30;I)Ljava/net/HttpURLConnection;
    .registers 9

    new-instance p2, Ly2/g;

    const/4 v0, 0x7

    invoke-direct {p2, v0}, Ly2/g;-><init>(I)V

    iput-object p2, p0, Lz5/g91;->r:Lz5/u91;

    iput-object p1, p0, Lz5/g91;->s:Lz5/u30;

    const/16 p1, 0x109

    .line 1
    invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p1

    .line 2
    invoke-virtual {p1}, Ljava/lang/Integer;->intValue()I

    iget-object p1, p0, Lz5/g91;->r:Lz5/u91;

    invoke-interface {p1}, Lz5/u91;->zza()Ljava/lang/Object;

    move-result-object p1

    check-cast p1, Ljava/lang/Integer;

    invoke-virtual {p1}, Ljava/lang/Integer;->intValue()I

    iget-object p1, p0, Lz5/g91;->s:Lz5/u30;

    invoke-static {p1}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;)Ljava/lang/Object;

    .line 3
    iget-object p1, p1, Lz5/u30;->r:Ljava/lang/String;

    sget-object p2, Lz5/i70;->w:Ljava/util/Set;

    invoke-static {}, Lcom/google/android/gms/ads/internal/zzt;->zzo()Lcom/google/android/gms/internal/ads/z1;

    sget-object p2, Lz5/so;->r:Lz5/no;

    .line 4
    sget-object v0, Lz5/xk;->d:Lz5/xk;

    iget-object v0, v0, Lz5/xk;->c:Lcom/google/android/gms/internal/ads/g0;

    .line 5
    invoke-virtual {v0, p2}, Lcom/google/android/gms/internal/ads/g0;->a(Lz5/no;)Ljava/lang/Object;

    move-result-object p2

    check-cast p2, Ljava/lang/Integer;

    invoke-virtual {p2}, Ljava/lang/Integer;->intValue()I

    move-result p2

    new-instance v0, Ljava/net/URL;

    invoke-direct {v0, p1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    const/4 p1, 0x0

    move v1, p1

    :goto_41
    add-int/lit8 v1, v1, 0x1

    const/16 v2, 0x14

    if-gt v1, v2, :cond_e2

    invoke-virtual {v0}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v2

    invoke-virtual {v2, p2}, Ljava/net/URLConnection;->setConnectTimeout(I)V

    invoke-virtual {v2, p2}, Ljava/net/URLConnection;->setReadTimeout(I)V

    instance-of v3, v2, Ljava/net/HttpURLConnection;

    if-eqz v3, :cond_da

    check-cast v2, Ljava/net/HttpURLConnection;

    new-instance v3, Lz5/c50;

    const/4 v4, 0x0

    invoke-direct {v3, v4}, Lz5/c50;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, v2, v4}, Lz5/c50;->a(Ljava/net/HttpURLConnection;[B)V

    invoke-virtual {v2, p1}, Ljava/net/HttpURLConnection;->setInstanceFollowRedirects(Z)V

    invoke-virtual {v2}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result v4

    invoke-virtual {v3, v2, v4}, Lz5/c50;->b(Ljava/net/HttpURLConnection;I)V

    div-int/lit8 v4, v4, 0x64

    const/4 v3, 0x3

    if-ne v4, v3, :cond_d7

    const-string v3, "Location"

    invoke-virtual {v2, v3}, Ljava/net/HttpURLConnection;->getHeaderField(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    if-eqz v3, :cond_cf

    new-instance v4, Ljava/net/URL;

    invoke-direct {v4, v0, v3}, Ljava/net/URL;-><init>(Ljava/net/URL;Ljava/lang/String;)V

    invoke-virtual {v4}, Ljava/net/URL;->getProtocol()Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_c7

    const-string v5, "http"

    invoke-virtual {v0, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-nez v5, :cond_ab

    const-string v5, "https"

    invoke-virtual {v0, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-nez v5, :cond_ab

    new-instance p1, Ljava/io/IOException;

    const-string p2, "Unsupported scheme: "

    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v1

    if-eqz v1, :cond_a1

    invoke-virtual {p2, v0}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p2

    goto :goto_a7

    :cond_a1
    new-instance v0, Ljava/lang/String;

    invoke-direct {v0, p2}, Ljava/lang/String;-><init>(Ljava/lang/String;)V

    move-object p2, v0

    :goto_a7
    invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw p1

    :cond_ab
    const-string v0, "Redirecting to "

    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v5

    if-eqz v5, :cond_b8

    invoke-virtual {v0, v3}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    goto :goto_be

    :cond_b8
    new-instance v3, Ljava/lang/String;

    invoke-direct {v3, v0}, Ljava/lang/String;-><init>(Ljava/lang/String;)V

    move-object v0, v3

    :goto_be
    invoke-static {v0}, Lz5/d50;->zzd(Ljava/lang/String;)V

    invoke-virtual {v2}, Ljava/net/HttpURLConnection;->disconnect()V

    move-object v0, v4

    goto/16 :goto_41

    :cond_c7
    new-instance p1, Ljava/io/IOException;

    const-string p2, "Protocol is null"

    invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw p1

    :cond_cf
    new-instance p1, Ljava/io/IOException;

    const-string p2, "Missing Location header in redirect"

    invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw p1

    .line 6
    :cond_d7
    iput-object v2, p0, Lz5/g91;->t:Ljava/net/HttpURLConnection;

    return-object v2

    .line 7
    :cond_da
    new-instance p1, Ljava/io/IOException;

    const-string p2, "Invalid protocol."

    invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw p1

    :cond_e2
    new-instance p1, Ljava/io/IOException;

    const-string p2, "Too many redirects (20)"

    invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public final close()V
    .registers 2

    iget-object v0, p0, Lz5/g91;->t:Ljava/net/HttpURLConnection;

    if-eqz v0, :cond_7

    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V

    :cond_7
    return-void
.end method
