KHttpPoster.smali

.class public Lcom/cmcm/support/http/KHttpPoster;
.super Ljava/lang/Object;

# interfaces
.implements Lcom/cmcm/support/http/IHttpSender;


# static fields
.field private static final TAG:Ljava/lang/String; = "KHttpPoster"


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

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

    return-void
.end method

.method private static getResponseData(Ljava/io/InputStream;)Ljava/lang/String;
    .registers 7

    const-string/jumbo v3, ""

    const-string/jumbo v0, ""

    const/4 v0, 0x0

    const/4 v2, 0x0

    :try_start_8
    new-instance v1, Ljava/io/BufferedReader;

    new-instance v4, Ljava/io/InputStreamReader;

    invoke-direct {v4, p0}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;)V

    invoke-direct {v1, v4}, Ljava/io/BufferedReader;-><init>(Ljava/io/Reader;)V
    :try_end_12
    .catch Ljava/lang/Throwable; {:try_start_8 .. :try_end_12} :catch_48
    .catchall {:try_start_8 .. :try_end_12} :catchall_54

    move-object v2, v3

    move v3, v0

    :goto_14
    :try_start_14
    invoke-virtual {v1}, Ljava/io/BufferedReader;->readLine()Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_69

    new-instance v4, Ljava/lang/StringBuilder;

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

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

    move-result-object v4

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

    move-result-object v0

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

    move-result-object v2

    new-instance v0, Ljava/lang/StringBuilder;

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

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

    move-result-object v0

    const-string/jumbo v4, "\r\n"

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

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
    :try_end_3e
    .catch Ljava/lang/Throwable; {:try_start_14 .. :try_end_3e} :catch_63
    .catchall {:try_start_14 .. :try_end_3e} :catchall_5e

    move-result-object v0

    add-int/lit8 v2, v3, 0x1

    const/4 v3, 0x4

    if-le v2, v3, :cond_6b

    :goto_44
    :try_start_44
    invoke-virtual {v1}, Ljava/io/BufferedReader;->close()V
    :try_end_47
    .catch Ljava/lang/Throwable; {:try_start_44 .. :try_end_47} :catch_5a

    :goto_47
    return-object v0

    :catch_48
    move-exception v0

    move-object v1, v0

    move-object v0, v3

    :goto_4b
    :try_start_4b
    invoke-virtual {v1}, Ljava/lang/Throwable;->printStackTrace()V
    :try_end_4e
    .catchall {:try_start_4b .. :try_end_4e} :catchall_60

    :try_start_4e
    invoke-virtual {v2}, Ljava/io/BufferedReader;->close()V
    :try_end_51
    .catch Ljava/lang/Throwable; {:try_start_4e .. :try_end_51} :catch_52

    goto :goto_47

    :catch_52
    move-exception v1

    goto :goto_47

    :catchall_54
    move-exception v0

    move-object v1, v2

    :goto_56
    :try_start_56
    invoke-virtual {v1}, Ljava/io/BufferedReader;->close()V
    :try_end_59
    .catch Ljava/lang/Throwable; {:try_start_56 .. :try_end_59} :catch_5c

    :goto_59
    throw v0

    :catch_5a
    move-exception v1

    goto :goto_47

    :catch_5c
    move-exception v1

    goto :goto_59

    :catchall_5e
    move-exception v0

    goto :goto_56

    :catchall_60
    move-exception v0

    move-object v1, v2

    goto :goto_56

    :catch_63
    move-exception v0

    move-object v5, v0

    move-object v0, v2

    move-object v2, v1

    move-object v1, v5

    goto :goto_4b

    :cond_69
    move-object v0, v2

    goto :goto_44

    :cond_6b
    move v3, v2

    move-object v2, v0

    goto :goto_14
.end method


# virtual methods
.method public httpPost(Lcom/cmcm/support/http/KHttpData;Ljava/lang/String;Lcom/cmcm/support/http/IHttpSender$OnResultListener;)Z
    .registers 16

    const/4 v6, 0x0

    const/4 v1, 0x1

    const/4 v2, 0x0

    const/4 v7, 0x0

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

    invoke-direct {v0, p2}, 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_f
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_f} :catch_99
    .catchall {:try_start_4 .. :try_end_f} :catchall_e0

    const/4 v3, 0x1

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

    const/4 v3, 0x1

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

    const-string/jumbo v3, "POST"

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

    new-instance v4, Ljava/io/ByteArrayOutputStream;

    invoke-direct {v4}, Ljava/io/ByteArrayOutputStream;-><init>()V
    :try_end_22
    .catch Ljava/lang/Exception; {:try_start_10 .. :try_end_22} :catch_131
    .catchall {:try_start_10 .. :try_end_22} :catchall_11a

    :try_start_22
    invoke-virtual {p1}, Lcom/cmcm/support/http/KHttpData;->getEncryptData()[B

    move-result-object v3

    const/4 v5, 0x0

    array-length v8, v3

    invoke-virtual {v4, v3, v5, v8}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getOutputStream()Ljava/io/OutputStream;
    :try_end_2e
    .catch Ljava/lang/Exception; {:try_start_22 .. :try_end_2e} :catch_139
    .catchall {:try_start_22 .. :try_end_2e} :catchall_121

    move-result-object v5

    :try_start_2f
    invoke-virtual {v4, v5}, Ljava/io/ByteArrayOutputStream;->writeTo(Ljava/io/OutputStream;)V

    sget-boolean v3, Lcom/cmcm/support/BuildConfig;->DEBUG:Z

    if-eqz v3, :cond_54

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

    move-result v3

    const-string/jumbo v8, "KHttpPoster"

    new-instance v9, Ljava/lang/StringBuilder;

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

    const-string/jumbo v10, "responseCode => "

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

    move-result-object v9

    invoke-virtual {v9, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

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

    move-result-object v3

    invoke-static {v8, v3}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

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

    move-result-object v3

    invoke-static {v3}, Lcom/cmcm/support/http/KHttpPoster;->getResponseData(Ljava/io/InputStream;)Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lcom/cmcm/support/http/HttpResult;->parserString(Ljava/lang/String;)Lcom/cmcm/support/http/HttpResult;
    :try_end_5f
    .catch Ljava/lang/Exception; {:try_start_2f .. :try_end_5f} :catch_141
    .catchall {:try_start_2f .. :try_end_5f} :catchall_127

    move-result-object v3

    if-eqz v3, :cond_159

    :try_start_62
    iget v8, v3, Lcom/cmcm/support/http/HttpResult;->nResult:I
    :try_end_64
    .catch Ljava/lang/Exception; {:try_start_62 .. :try_end_64} :catch_149
    .catchall {:try_start_62 .. :try_end_64} :catchall_127

    if-ne v8, v1, :cond_159

    :goto_66
    if-eqz v0, :cond_6b

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

    :cond_6b
    if-eqz v5, :cond_70

    :try_start_6d
    invoke-virtual {v5}, Ljava/io/OutputStream;->close()V
    :try_end_70
    .catch Ljava/io/IOException; {:try_start_6d .. :try_end_70} :catch_89

    :cond_70
    :goto_70
    if-eqz v4, :cond_75

    :try_start_72
    invoke-virtual {v4}, Ljava/io/ByteArrayOutputStream;->close()V
    :try_end_75
    .catch Ljava/io/IOException; {:try_start_72 .. :try_end_75} :catch_8e

    :cond_75
    :goto_75
    if-eqz v2, :cond_156

    :try_start_77
    invoke-virtual {v7}, Ljava/io/BufferedReader;->close()V
    :try_end_7a
    .catch Ljava/io/IOException; {:try_start_77 .. :try_end_7a} :catch_93

    move v0, v1

    :goto_7b
    if-eqz p3, :cond_88

    if-eqz v0, :cond_108

    if-eqz v3, :cond_108

    iget-wide v4, v3, Lcom/cmcm/support/http/HttpResult;->nServeTime:J

    iget-object v1, v3, Lcom/cmcm/support/http/HttpResult;->byKey:[B

    invoke-interface {p3, v4, v5, v1, p1}, Lcom/cmcm/support/http/IHttpSender$OnResultListener;->onSuccess(J[BLcom/cmcm/support/http/KHttpData;)V

    :cond_88
    :goto_88
    return v0

    :catch_89
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_70

    :catch_8e
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_75

    :catch_93
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    move v0, v1

    goto :goto_7b

    :catch_99
    move-exception v0

    move-object v1, v2

    move-object v3, v2

    move-object v4, v2

    move-object v5, v2

    :goto_9e
    :try_start_9e
    const-string/jumbo v8, "KHttpPoster"

    new-instance v9, Ljava/lang/StringBuilder;

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

    const-string/jumbo v10, "Exception => "

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

    move-result-object v9

    invoke-virtual {v9, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v0

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

    move-result-object v0

    invoke-static {v8, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_b8
    .catchall {:try_start_9e .. :try_end_b8} :catchall_12c

    if-eqz v5, :cond_bd

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

    :cond_bd
    if-eqz v4, :cond_c2

    :try_start_bf
    invoke-virtual {v4}, Ljava/io/OutputStream;->close()V
    :try_end_c2
    .catch Ljava/io/IOException; {:try_start_bf .. :try_end_c2} :catch_cf

    :cond_c2
    :goto_c2
    if-eqz v3, :cond_c7

    :try_start_c4
    invoke-virtual {v3}, Ljava/io/ByteArrayOutputStream;->close()V
    :try_end_c7
    .catch Ljava/io/IOException; {:try_start_c4 .. :try_end_c7} :catch_d4

    :cond_c7
    :goto_c7
    if-eqz v2, :cond_152

    :try_start_c9
    invoke-virtual {v7}, Ljava/io/BufferedReader;->close()V
    :try_end_cc
    .catch Ljava/io/IOException; {:try_start_c9 .. :try_end_cc} :catch_d9

    move v0, v6

    move-object v3, v1

    goto :goto_7b

    :catch_cf
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_c2

    :catch_d4
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_c7

    :catch_d9
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    move v0, v6

    move-object v3, v1

    goto :goto_7b

    :catchall_e0
    move-exception v0

    move-object v4, v2

    move-object v5, v2

    move-object v1, v2

    :goto_e4
    if-eqz v1, :cond_e9

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

    :cond_e9
    if-eqz v5, :cond_ee

    :try_start_eb
    invoke-virtual {v5}, Ljava/io/OutputStream;->close()V
    :try_end_ee
    .catch Ljava/io/IOException; {:try_start_eb .. :try_end_ee} :catch_f9

    :cond_ee
    :goto_ee
    if-eqz v4, :cond_f3

    :try_start_f0
    invoke-virtual {v4}, Ljava/io/ByteArrayOutputStream;->close()V
    :try_end_f3
    .catch Ljava/io/IOException; {:try_start_f0 .. :try_end_f3} :catch_fe

    :cond_f3
    :goto_f3
    if-eqz v2, :cond_f8

    :try_start_f5
    invoke-virtual {v7}, Ljava/io/BufferedReader;->close()V
    :try_end_f8
    .catch Ljava/io/IOException; {:try_start_f5 .. :try_end_f8} :catch_103

    :cond_f8
    :goto_f8
    throw v0

    :catch_f9
    move-exception v1

    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_ee

    :catch_fe
    move-exception v1

    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_f3

    :catch_103
    move-exception v1

    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_f8

    :cond_108
    if-eqz v3, :cond_113

    iget-wide v4, v3, Lcom/cmcm/support/http/HttpResult;->nServeTime:J

    iget-object v1, v3, Lcom/cmcm/support/http/HttpResult;->byKey:[B

    invoke-interface {p3, v4, v5, v1, p1}, Lcom/cmcm/support/http/IHttpSender$OnResultListener;->onFail(J[BLcom/cmcm/support/http/KHttpData;)V

    goto/16 :goto_88

    :cond_113
    const-wide/16 v4, 0x0

    invoke-interface {p3, v4, v5, v2, p1}, Lcom/cmcm/support/http/IHttpSender$OnResultListener;->onFail(J[BLcom/cmcm/support/http/KHttpData;)V

    goto/16 :goto_88

    :catchall_11a
    move-exception v1

    move-object v4, v2

    move-object v5, v2

    move-object v11, v1

    move-object v1, v0

    move-object v0, v11

    goto :goto_e4

    :catchall_121
    move-exception v1

    move-object v5, v2

    move-object v11, v1

    move-object v1, v0

    move-object v0, v11

    goto :goto_e4

    :catchall_127
    move-exception v1

    move-object v11, v1

    move-object v1, v0

    move-object v0, v11

    goto :goto_e4

    :catchall_12c
    move-exception v0

    move-object v1, v5

    move-object v5, v4

    move-object v4, v3

    goto :goto_e4

    :catch_131
    move-exception v1

    move-object v3, v2

    move-object v4, v2

    move-object v5, v0

    move-object v0, v1

    move-object v1, v2

    goto/16 :goto_9e

    :catch_139
    move-exception v1

    move-object v3, v4

    move-object v5, v0

    move-object v0, v1

    move-object v4, v2

    move-object v1, v2

    goto/16 :goto_9e

    :catch_141
    move-exception v1

    move-object v3, v4

    move-object v4, v5

    move-object v5, v0

    move-object v0, v1

    move-object v1, v2

    goto/16 :goto_9e

    :catch_149
    move-exception v1

    move-object v11, v1

    move-object v1, v3

    move-object v3, v4

    move-object v4, v5

    move-object v5, v0

    move-object v0, v11

    goto/16 :goto_9e

    :cond_152
    move v0, v6

    move-object v3, v1

    goto/16 :goto_7b

    :cond_156
    move v0, v1

    goto/16 :goto_7b

    :cond_159
    move v1, v6

    goto/16 :goto_66
.end method