zzap.smali

.class final Lcom/google/android/gms/internal/firebase_ml/zzap;
.super Lcom/google/android/gms/internal/firebase_ml/zzah;


# instance fields
.field private final zzcs:Ljava/net/HttpURLConnection;


# direct methods
.method constructor <init>(Ljava/net/HttpURLConnection;)V
    .registers 3

    invoke-direct {p0}, Lcom/google/android/gms/internal/firebase_ml/zzah;-><init>()V

    iput-object p1, p0, Lcom/google/android/gms/internal/firebase_ml/zzap;->zzcs:Ljava/net/HttpURLConnection;

    const/4 v0, 0x0

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

    return-void
.end method


# virtual methods
.method public final addHeader(Ljava/lang/String;Ljava/lang/String;)V
    .registers 4

    iget-object v0, p0, Lcom/google/android/gms/internal/firebase_ml/zzap;->zzcs:Ljava/net/HttpURLConnection;

    invoke-virtual {v0, p1, p2}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    return-void
.end method

.method public final zza(II)V
    .registers 4

    iget-object v0, p0, Lcom/google/android/gms/internal/firebase_ml/zzap;->zzcs:Ljava/net/HttpURLConnection;

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

    iget-object v0, p0, Lcom/google/android/gms/internal/firebase_ml/zzap;->zzcs:Ljava/net/HttpURLConnection;

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

    return-void
.end method

.method public final zzaf()Lcom/google/android/gms/internal/firebase_ml/zzai;
    .registers 11

    const-wide/16 v8, 0x0

    const/4 v1, 0x1

    const/4 v2, 0x0

    iget-object v3, p0, Lcom/google/android/gms/internal/firebase_ml/zzap;->zzcs:Ljava/net/HttpURLConnection;

    invoke-virtual {p0}, Lcom/google/android/gms/internal/firebase_ml/zzah;->zzae()Lcom/google/android/gms/internal/firebase_ml/zzco;

    move-result-object v0

    if-eqz v0, :cond_67

    invoke-virtual {p0}, Lcom/google/android/gms/internal/firebase_ml/zzah;->getContentType()Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_17

    const-string v4, "Content-Type"

    invoke-virtual {p0, v4, v0}, Lcom/google/android/gms/internal/firebase_ml/zzah;->addHeader(Ljava/lang/String;Ljava/lang/String;)V

    :cond_17
    invoke-virtual {p0}, Lcom/google/android/gms/internal/firebase_ml/zzah;->getContentEncoding()Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_22

    const-string v4, "Content-Encoding"

    invoke-virtual {p0, v4, v0}, Lcom/google/android/gms/internal/firebase_ml/zzah;->addHeader(Ljava/lang/String;Ljava/lang/String;)V

    :cond_22
    invoke-virtual {p0}, Lcom/google/android/gms/internal/firebase_ml/zzah;->getContentLength()J

    move-result-wide v4

    cmp-long v0, v4, v8

    if-ltz v0, :cond_33

    const-string v0, "Content-Length"

    invoke-static {v4, v5}, Ljava/lang/Long;->toString(J)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {p0, v0, v6}, Lcom/google/android/gms/internal/firebase_ml/zzah;->addHeader(Ljava/lang/String;Ljava/lang/String;)V

    :cond_33
    invoke-virtual {v3}, Ljava/net/HttpURLConnection;->getRequestMethod()Ljava/lang/String;

    move-result-object v6

    const-string v0, "POST"

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

    move-result v0

    if-nez v0, :cond_47

    const-string v0, "PUT"

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

    move-result v0

    if-eqz v0, :cond_7b

    :cond_47
    invoke-virtual {v3, v1}, Ljava/net/HttpURLConnection;->setDoOutput(Z)V

    cmp-long v0, v4, v8

    if-ltz v0, :cond_70

    const-wide/32 v0, 0x7fffffff

    cmp-long v0, v4, v0

    if-gtz v0, :cond_70

    long-to-int v0, v4

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

    :goto_59
    invoke-virtual {v3}, Ljava/net/HttpURLConnection;->getOutputStream()Ljava/io/OutputStream;

    move-result-object v1

    :try_start_5d
    invoke-virtual {p0}, Lcom/google/android/gms/internal/firebase_ml/zzah;->zzae()Lcom/google/android/gms/internal/firebase_ml/zzco;

    move-result-object v0

    invoke-interface {v0, v1}, Lcom/google/android/gms/internal/firebase_ml/zzco;->writeTo(Ljava/io/OutputStream;)V
    :try_end_64
    .catchall {:try_start_5d .. :try_end_64} :catchall_76

    :try_start_64
    invoke-virtual {v1}, Ljava/io/OutputStream;->close()V
    :try_end_67
    .catch Ljava/io/IOException; {:try_start_64 .. :try_end_67} :catch_74

    :cond_67
    :goto_67
    :try_start_67
    invoke-virtual {v3}, Ljava/net/HttpURLConnection;->connect()V

    new-instance v0, Lcom/google/android/gms/internal/firebase_ml/zzaq;

    invoke-direct {v0, v3}, Lcom/google/android/gms/internal/firebase_ml/zzaq;-><init>(Ljava/net/HttpURLConnection;)V
    :try_end_6f
    .catchall {:try_start_67 .. :try_end_6f} :catchall_8c

    return-object v0

    :cond_70
    invoke-virtual {v3, v2}, Ljava/net/HttpURLConnection;->setChunkedStreamingMode(I)V

    goto :goto_59

    :catch_74
    move-exception v0

    throw v0

    :catchall_76
    move-exception v0

    :try_start_77
    invoke-virtual {v1}, Ljava/io/OutputStream;->close()V
    :try_end_7a
    .catch Ljava/io/IOException; {:try_start_77 .. :try_end_7a} :catch_91

    :goto_7a
    throw v0

    :cond_7b
    cmp-long v0, v4, v8

    if-nez v0, :cond_8a

    move v0, v1

    :goto_80
    const-string v4, "%s with non-zero content length is not supported"

    new-array v1, v1, [Ljava/lang/Object;

    aput-object v6, v1, v2

    invoke-static {v0, v4, v1}, Lcom/google/android/gms/internal/firebase_ml/zzfl;->checkArgument(ZLjava/lang/String;[Ljava/lang/Object;)V

    goto :goto_67

    :cond_8a
    move v0, v2

    goto :goto_80

    :catchall_8c
    move-exception v0

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

    throw v0

    :catch_91
    move-exception v1

    goto :goto_7a
.end method