AndroidHttpClient.smali

.class public Lcom/facebook/biddingkit/http/client/AndroidHttpClient;
.super Ljava/lang/Object;


# instance fields
.field protected a:I

.field protected b:I

.field protected c:Ljava/lang/String;

.field private d:Ljava/util/Set;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Set<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private e:Ljava/util/Set;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Set<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private f:I

.field private g:Z

.field private h:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


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

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

    const/16 v0, 0x7d0

    iput v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a:I

    const/16 v0, 0x1f40

    iput v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b:I

    const-string v0, "UTF-8"

    iput-object v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->c:Ljava/lang/String;

    const/4 v0, 0x3

    iput v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->f:I

    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->g:Z

    new-instance v0, Ljava/util/TreeMap;

    invoke-direct {v0}, Ljava/util/TreeMap;-><init>()V

    iput-object v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->h:Ljava/util/Map;

    return-void
.end method

.method private a(Ljava/io/InputStream;)[B
    .registers 6

    const/16 v0, 0x4000

    new-array v0, v0, [B

    new-instance v1, Ljava/io/ByteArrayOutputStream;

    invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V

    :goto_9
    invoke-virtual {p1, v0}, Ljava/io/InputStream;->read([B)I

    move-result v2

    const/4 v3, -0x1

    if-eq v2, v3, :cond_15

    const/4 v3, 0x0

    invoke-virtual {v1, v0, v3, v2}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    goto :goto_9

    :cond_15
    invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->flush()V

    invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object p1

    return-object p1
.end method

.method private b(I)I
    .registers 3

    const/4 v0, 0x1

    if-le p1, v0, :cond_16

    const/16 v0, 0x14

    if-le p1, v0, :cond_8

    goto :goto_16

    :cond_8
    add-int/lit8 v0, p1, -0x1

    invoke-direct {p0, v0}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b(I)I

    move-result v0

    add-int/lit8 p1, p1, -0x2

    invoke-direct {p0, p1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b(I)I

    move-result p1

    add-int/2addr v0, p1

    return v0

    :cond_16
    :goto_16
    return p1
.end method

.method private c(Ljava/net/HttpURLConnection;)V
    .registers 5

    iget-object v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->h:Ljava/util/Map;

    invoke-interface {v0}, Ljava/util/Map;->keySet()Ljava/util/Set;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :goto_a
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_22

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    iget-object v2, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->h:Ljava/util/Map;

    invoke-interface {v2, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    invoke-virtual {p1, v1, v2}, Ljava/net/HttpURLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_a

    :cond_22
    iget-object v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->c:Ljava/lang/String;

    const-string v1, "Accept-Charset"

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

    return-void
.end method


# virtual methods
.method protected a(I)I
    .registers 2

    add-int/lit8 p1, p1, 0x2

    invoke-direct {p0, p1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b(I)I

    move-result p1

    mul-int/lit16 p1, p1, 0x3e8

    return p1
.end method

.method protected a(Ljava/net/HttpURLConnection;[B)I
    .registers 4

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

    move-result-object v0
    :try_end_4
    .catchall {:try_start_0 .. :try_end_4} :catchall_15

    if-eqz v0, :cond_9

    :try_start_6
    invoke-virtual {v0, p2}, Ljava/io/OutputStream;->write([B)V

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

    move-result p1
    :try_end_d
    .catchall {:try_start_6 .. :try_end_d} :catchall_13

    if-eqz v0, :cond_12

    :try_start_f
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_12
    .catch Ljava/lang/Exception; {:try_start_f .. :try_end_12} :catch_12

    :catch_12
    :cond_12
    return p1

    :catchall_13
    move-exception p1

    goto :goto_17

    :catchall_15
    move-exception p1

    const/4 v0, 0x0

    :goto_17
    if-eqz v0, :cond_1c

    :try_start_19
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_1c
    .catch Ljava/lang/Exception; {:try_start_19 .. :try_end_1c} :catch_1c

    :catch_1c
    :cond_1c
    throw p1
.end method

.method protected a(Ljava/lang/String;Lcom/facebook/biddingkit/http/client/HttpMethod;Ljava/lang/String;[B)Lcom/facebook/biddingkit/http/client/HttpResponse;
    .registers 9

    const-string v0, "AndroidHttpClient"

    const/4 v1, 0x0

    const/4 v2, 0x0

    :try_start_4
    iput-boolean v1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->g:Z

    invoke-virtual {p0, p1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/lang/String;)Ljava/net/HttpURLConnection;

    move-result-object p1
    :try_end_a
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_a} :catch_74
    .catchall {:try_start_4 .. :try_end_a} :catchall_71

    :try_start_a
    invoke-virtual {p0, p1, p2, p3}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/net/HttpURLConnection;Lcom/facebook/biddingkit/http/client/HttpMethod;Ljava/lang/String;)V

    invoke-direct {p0, p1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->c(Ljava/net/HttpURLConnection;)V

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

    const/4 p2, 0x1

    iput-boolean p2, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->g:Z

    iget-object p3, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->e:Ljava/util/Set;

    if-eqz p3, :cond_24

    iget-object p3, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->e:Ljava/util/Set;

    invoke-interface {p3}, Ljava/util/Set;->isEmpty()Z

    move-result p3

    if-nez p3, :cond_24

    const/4 p3, 0x1

    goto :goto_25

    :cond_24
    const/4 p3, 0x0

    :goto_25
    iget-object v3, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->d:Ljava/util/Set;

    if-eqz v3, :cond_32

    iget-object v3, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->d:Ljava/util/Set;

    invoke-interface {v3}, Ljava/util/Set;->isEmpty()Z

    move-result v3

    if-nez v3, :cond_32

    goto :goto_33

    :cond_32
    const/4 p2, 0x0

    :goto_33
    instance-of v1, p1, Ljavax/net/ssl/HttpsURLConnection;
    :try_end_35
    .catch Ljava/lang/Exception; {:try_start_a .. :try_end_35} :catch_6f
    .catchall {:try_start_a .. :try_end_35} :catchall_6d

    if-eqz v1, :cond_4c

    if-nez p3, :cond_3b

    if-eqz p2, :cond_4c

    :cond_3b
    :try_start_3b
    move-object p2, p1

    check-cast p2, Ljavax/net/ssl/HttpsURLConnection;

    iget-object p3, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->e:Ljava/util/Set;

    iget-object v1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->d:Ljava/util/Set;

    invoke-static {p2, p3, v1}, Lcom/facebook/biddingkit/http/client/KeyPinningValidator;->validatePinning(Ljavax/net/ssl/HttpsURLConnection;Ljava/util/Set;Ljava/util/Set;)V
    :try_end_45
    .catch Ljava/lang/Exception; {:try_start_3b .. :try_end_45} :catch_46
    .catchall {:try_start_3b .. :try_end_45} :catchall_6d

    goto :goto_4c

    :catch_46
    move-exception p2

    :try_start_47
    const-string p3, "Unable to validate SSL certificates: "

    invoke-static {v0, p3, p2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    :cond_4c
    :goto_4c
    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getDoOutput()Z

    move-result p2

    if-eqz p2, :cond_57

    if-eqz p4, :cond_57

    invoke-virtual {p0, p1, p4}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/net/HttpURLConnection;[B)I

    :cond_57
    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getDoInput()Z

    move-result p2

    if-eqz p2, :cond_62

    invoke-virtual {p0, p1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/net/HttpURLConnection;)Lcom/facebook/biddingkit/http/client/HttpResponse;

    move-result-object p2

    goto :goto_67

    :cond_62
    new-instance p2, Lcom/facebook/biddingkit/http/client/HttpResponse;

    invoke-direct {p2, p1, v2}, Lcom/facebook/biddingkit/http/client/HttpResponse;-><init>(Ljava/net/HttpURLConnection;[B)V
    :try_end_67
    .catch Ljava/lang/Exception; {:try_start_47 .. :try_end_67} :catch_6f
    .catchall {:try_start_47 .. :try_end_67} :catchall_6d

    :goto_67
    if-eqz p1, :cond_6c

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

    :cond_6c
    return-object p2

    :catchall_6d
    move-exception p2

    goto :goto_9f

    :catch_6f
    move-exception p2

    goto :goto_76

    :catchall_71
    move-exception p2

    move-object p1, v2

    goto :goto_9f

    :catch_74
    move-exception p2

    move-object p1, v2

    :goto_76
    :try_start_76
    invoke-virtual {p0, p1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b(Ljava/net/HttpURLConnection;)Lcom/facebook/biddingkit/http/client/HttpResponse;

    move-result-object p3
    :try_end_7a
    .catch Ljava/lang/Exception; {:try_start_76 .. :try_end_7a} :catch_8e
    .catchall {:try_start_76 .. :try_end_7a} :catchall_99

    if-eqz p3, :cond_88

    :try_start_7c
    invoke-virtual {p3}, Lcom/facebook/biddingkit/http/client/HttpResponse;->getStatus()I

    move-result p4
    :try_end_80
    .catchall {:try_start_7c .. :try_end_80} :catchall_6d

    if-lez p4, :cond_88

    if-eqz p1, :cond_87

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

    :cond_87
    return-object p3

    :cond_88
    :try_start_88
    new-instance p4, Lcom/facebook/biddingkit/http/client/HttpRequestException;

    invoke-direct {p4, p2, p3}, Lcom/facebook/biddingkit/http/client/HttpRequestException;-><init>(Ljava/lang/Exception;Lcom/facebook/biddingkit/http/client/HttpResponse;)V

    throw p4
    :try_end_8e
    .catchall {:try_start_88 .. :try_end_8e} :catchall_6d

    :catch_8e
    :try_start_8e
    const-string p3, "Failed http method: "

    invoke-static {v0, p3, p2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
    :try_end_93
    .catchall {:try_start_8e .. :try_end_93} :catchall_99

    :try_start_93
    new-instance p3, Lcom/facebook/biddingkit/http/client/HttpRequestException;

    invoke-direct {p3, p2, v2}, Lcom/facebook/biddingkit/http/client/HttpRequestException;-><init>(Ljava/lang/Exception;Lcom/facebook/biddingkit/http/client/HttpResponse;)V

    throw p3

    :catchall_99
    new-instance p3, Lcom/facebook/biddingkit/http/client/HttpRequestException;

    invoke-direct {p3, p2, v2}, Lcom/facebook/biddingkit/http/client/HttpRequestException;-><init>(Ljava/lang/Exception;Lcom/facebook/biddingkit/http/client/HttpResponse;)V

    throw p3
    :try_end_9f
    .catchall {:try_start_93 .. :try_end_9f} :catchall_6d

    :goto_9f
    if-eqz p1, :cond_a4

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

    :cond_a4
    throw p2
.end method

.method protected a(Ljava/net/HttpURLConnection;)Lcom/facebook/biddingkit/http/client/HttpResponse;
    .registers 5

    const/4 v0, 0x0

    :try_start_1
    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;

    move-result-object v1
    :try_end_5
    .catchall {:try_start_1 .. :try_end_5} :catchall_18

    if-eqz v1, :cond_b

    :try_start_7
    invoke-direct {p0, v1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/io/InputStream;)[B

    move-result-object v0

    :cond_b
    new-instance v2, Lcom/facebook/biddingkit/http/client/HttpResponse;

    invoke-direct {v2, p1, v0}, Lcom/facebook/biddingkit/http/client/HttpResponse;-><init>(Ljava/net/HttpURLConnection;[B)V
    :try_end_10
    .catchall {:try_start_7 .. :try_end_10} :catchall_16

    if-eqz v1, :cond_15

    :try_start_12
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V
    :try_end_15
    .catch Ljava/lang/Exception; {:try_start_12 .. :try_end_15} :catch_15

    :catch_15
    :cond_15
    return-object v2

    :catchall_16
    move-exception p1

    goto :goto_1a

    :catchall_18
    move-exception p1

    move-object v1, v0

    :goto_1a
    if-eqz v1, :cond_1f

    :try_start_1c
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V
    :try_end_1f
    .catch Ljava/lang/Exception; {:try_start_1c .. :try_end_1f} :catch_1f

    :catch_1f
    :cond_1f
    throw p1
.end method

.method protected a(Ljava/lang/String;)Ljava/net/HttpURLConnection;
    .registers 5

    :try_start_0
    new-instance v0, Ljava/net/URL;

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

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

    move-result-object v0

    check-cast v0, Ljava/net/HttpURLConnection;
    :try_end_b
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_b} :catch_c

    return-object v0

    :catch_c
    move-exception v0

    new-instance v1, Ljava/lang/IllegalArgumentException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string p1, " is not a valid URL"

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-direct {v1, p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v1
.end method

.method protected a(Ljava/net/HttpURLConnection;Lcom/facebook/biddingkit/http/client/HttpMethod;Ljava/lang/String;)V
    .registers 5

    iget v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a:I

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

    iget v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b:I

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

    invoke-virtual {p2}, Lcom/facebook/biddingkit/http/client/HttpMethod;->getMethodName()Ljava/lang/String;

    move-result-object v0

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

    invoke-virtual {p2}, Lcom/facebook/biddingkit/http/client/HttpMethod;->getDoOutput()Z

    move-result v0

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

    invoke-virtual {p2}, Lcom/facebook/biddingkit/http/client/HttpMethod;->getDoInput()Z

    move-result p2

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

    if-eqz p3, :cond_26

    const-string p2, "Content-Type"

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

    :cond_26
    return-void
.end method

.method protected a(Ljava/lang/Throwable;J)Z
    .registers 8

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    sub-long/2addr v0, p2

    const-wide/16 p1, 0xa

    add-long/2addr v0, p1

    iget-boolean p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->g:Z

    const/4 p2, 0x1

    const/4 p3, 0x0

    if-eqz p1, :cond_18

    iget p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b:I

    int-to-long v2, p1

    cmp-long p1, v0, v2

    if-ltz p1, :cond_16

    goto :goto_17

    :cond_16
    const/4 p2, 0x0

    :goto_17
    return p2

    :cond_18
    iget p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a:I

    int-to-long v2, p1

    cmp-long p1, v0, v2

    if-ltz p1, :cond_20

    goto :goto_21

    :cond_20
    const/4 p2, 0x0

    :goto_21
    return p2
.end method

.method public addHeader(Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/biddingkit/http/client/AndroidHttpClient;
    .registers 4

    iget-object v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->h:Ljava/util/Map;

    invoke-interface {v0, p1, p2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    return-object p0
.end method

.method protected b(Ljava/net/HttpURLConnection;)Lcom/facebook/biddingkit/http/client/HttpResponse;
    .registers 5

    const/4 v0, 0x0

    :try_start_1
    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getErrorStream()Ljava/io/InputStream;

    move-result-object v1
    :try_end_5
    .catchall {:try_start_1 .. :try_end_5} :catchall_18

    if-eqz v1, :cond_b

    :try_start_7
    invoke-direct {p0, v1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/io/InputStream;)[B

    move-result-object v0

    :cond_b
    new-instance v2, Lcom/facebook/biddingkit/http/client/HttpResponse;

    invoke-direct {v2, p1, v0}, Lcom/facebook/biddingkit/http/client/HttpResponse;-><init>(Ljava/net/HttpURLConnection;[B)V
    :try_end_10
    .catchall {:try_start_7 .. :try_end_10} :catchall_16

    if-eqz v1, :cond_15

    :try_start_12
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V
    :try_end_15
    .catch Ljava/lang/Exception; {:try_start_12 .. :try_end_15} :catch_15

    :catch_15
    :cond_15
    return-object v2

    :catchall_16
    move-exception p1

    goto :goto_1a

    :catchall_18
    move-exception p1

    move-object v1, v0

    :goto_1a
    if-eqz v1, :cond_1f

    :try_start_1c
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V
    :try_end_1f
    .catch Ljava/lang/Exception; {:try_start_1c .. :try_end_1f} :catch_1f

    :catch_1f
    :cond_1f
    throw p1
.end method

.method public execute(Lcom/facebook/biddingkit/http/client/HttpRequest;)Lcom/facebook/biddingkit/http/client/HttpResponse;
    .registers 5

    const-string v0, "AndroidHttpClient"

    const/4 v1, 0x0

    :try_start_3
    invoke-virtual {p0, p1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->tryMany(Lcom/facebook/biddingkit/http/client/HttpRequest;)Lcom/facebook/biddingkit/http/client/HttpResponse;

    move-result-object v1
    :try_end_7
    .catch Lcom/facebook/biddingkit/http/client/HttpRequestException; {:try_start_3 .. :try_end_7} :catch_14
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_7} :catch_8

    goto :goto_1a

    :catch_8
    move-exception p1

    new-instance v2, Lcom/facebook/biddingkit/http/client/HttpRequestException;

    invoke-direct {v2, p1, v1}, Lcom/facebook/biddingkit/http/client/HttpRequestException;-><init>(Ljava/lang/Exception;Lcom/facebook/biddingkit/http/client/HttpResponse;)V

    const-string p1, "Unable to send request and got a RuntimeException: "

    invoke-static {v0, p1, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_1a

    :catch_14
    move-exception p1

    const-string v2, "Unable to send request and got a HttpRequestException: "

    invoke-static {v0, v2, p1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    :goto_1a
    return-object v1
.end method

.method public get(Ljava/lang/String;Ljava/util/Map;)Lcom/facebook/biddingkit/http/client/HttpResponse;
    .registers 4
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;)",
            "Lcom/facebook/biddingkit/http/client/HttpResponse;"
        }
    .end annotation

    new-instance v0, Lcom/facebook/biddingkit/http/client/HttpGet;

    invoke-direct {v0, p1, p2}, Lcom/facebook/biddingkit/http/client/HttpGet;-><init>(Ljava/lang/String;Ljava/util/Map;)V

    invoke-virtual {p0, v0}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->execute(Lcom/facebook/biddingkit/http/client/HttpRequest;)Lcom/facebook/biddingkit/http/client/HttpResponse;

    move-result-object p1

    return-object p1
.end method

.method public getRequestHeaders()Ljava/util/Map;
    .registers 2
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    iget-object v0, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->h:Ljava/util/Map;

    return-object v0
.end method

.method public isRecoverable(Lcom/facebook/biddingkit/http/client/HttpRequestException;)Z
    .registers 2

    invoke-virtual {p1}, Lcom/facebook/biddingkit/http/client/HttpRequestException;->getHttpResponse()Lcom/facebook/biddingkit/http/client/HttpResponse;

    move-result-object p1

    if-eqz p1, :cond_e

    invoke-virtual {p1}, Lcom/facebook/biddingkit/http/client/HttpResponse;->getStatus()I

    move-result p1

    if-lez p1, :cond_e

    const/4 p1, 0x1

    return p1

    :cond_e
    const/4 p1, 0x0

    return p1
.end method

.method public post(Ljava/lang/String;Ljava/lang/String;[B)Lcom/facebook/biddingkit/http/client/HttpResponse;
    .registers 6

    new-instance v0, Lcom/facebook/biddingkit/http/client/HttpPost;

    const/4 v1, 0x0

    invoke-direct {v0, p1, v1, p2, p3}, Lcom/facebook/biddingkit/http/client/HttpPost;-><init>(Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;[B)V

    invoke-virtual {p0, v0}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->execute(Lcom/facebook/biddingkit/http/client/HttpRequest;)Lcom/facebook/biddingkit/http/client/HttpResponse;

    move-result-object p1

    return-object p1
.end method

.method public setConnectionTimeout(I)V
    .registers 2

    iput p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a:I

    return-void
.end method

.method public setMaxRetries(I)V
    .registers 3

    const/4 v0, 0x1

    if-lt p1, v0, :cond_a

    const/16 v0, 0x12

    if-gt p1, v0, :cond_a

    iput p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->f:I

    return-void

    :cond_a
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string v0, "Maximum retries must be between 1 and 18"

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

    throw p1
.end method

.method public setPinnedCertificates(Ljava/util/Set;)V
    .registers 2
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Set<",
            "Ljava/lang/String;",
            ">;)V"
        }
    .end annotation

    iput-object p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->e:Ljava/util/Set;

    return-void
.end method

.method public setPinnedPublicKeys(Ljava/util/Set;)V
    .registers 2
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Set<",
            "Ljava/lang/String;",
            ">;)V"
        }
    .end annotation

    iput-object p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->d:Ljava/util/Set;

    return-void
.end method

.method public setReadTimeout(I)V
    .registers 2

    iput p1, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->b:I

    return-void
.end method

.method public tryMany(Lcom/facebook/biddingkit/http/client/HttpRequest;)Lcom/facebook/biddingkit/http/client/HttpResponse;
    .registers 10

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    const/4 v2, 0x0

    const/4 v3, 0x0

    :goto_6
    iget v4, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->f:I

    if-ge v2, v4, :cond_5d

    :try_start_a
    invoke-virtual {p0, v2}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(I)I

    move-result v4

    invoke-virtual {p0, v4}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->setConnectionTimeout(I)V

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    invoke-virtual {p1}, Lcom/facebook/biddingkit/http/client/HttpRequest;->getPath()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {p1}, Lcom/facebook/biddingkit/http/client/HttpRequest;->getHttpMethod()Lcom/facebook/biddingkit/http/client/HttpMethod;

    move-result-object v5

    invoke-virtual {p1}, Lcom/facebook/biddingkit/http/client/HttpRequest;->getContentType()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {p1}, Lcom/facebook/biddingkit/http/client/HttpRequest;->getContent()[B

    move-result-object v7

    invoke-virtual {p0, v4, v5, v6, v7}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/lang/String;Lcom/facebook/biddingkit/http/client/HttpMethod;Ljava/lang/String;[B)Lcom/facebook/biddingkit/http/client/HttpResponse;

    move-result-object v3
    :try_end_29
    .catch Lcom/facebook/biddingkit/http/client/HttpRequestException; {:try_start_a .. :try_end_29} :catch_2c

    if-eqz v3, :cond_4e

    return-object v3

    :catch_2c
    move-exception v4

    invoke-virtual {p0, v4, v0, v1}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a(Ljava/lang/Throwable;J)Z

    move-result v5

    if-eqz v5, :cond_3a

    iget v5, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->f:I

    add-int/lit8 v5, v5, -0x1

    if-ge v2, v5, :cond_3a

    goto :goto_4e

    :cond_3a
    invoke-virtual {p0, v4}, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->isRecoverable(Lcom/facebook/biddingkit/http/client/HttpRequestException;)Z

    move-result v5

    const-string v6, "AndroidHttpClient"

    if-eqz v5, :cond_58

    iget v5, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->f:I

    add-int/lit8 v5, v5, -0x1

    if-ge v2, v5, :cond_58

    :try_start_48
    iget v4, p0, Lcom/facebook/biddingkit/http/client/AndroidHttpClient;->a:I

    int-to-long v4, v4

    invoke-static {v4, v5}, Ljava/lang/Thread;->sleep(J)V
    :try_end_4e
    .catch Ljava/lang/InterruptedException; {:try_start_48 .. :try_end_4e} :catch_51

    :cond_4e
    :goto_4e
    add-int/lit8 v2, v2, 0x1

    goto :goto_6

    :catch_51
    move-exception p1

    const-string v0, "App is stopping: "

    invoke-static {v6, v0, p1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_5d

    :cond_58
    const-string p1, "Unable to send request: "

    invoke-static {v6, p1, v4}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    :cond_5d
    :goto_5d
    return-object v3
.end method