164 lines
4.7 KiB
Smali
164 lines
4.7 KiB
Smali
|
.class Lcom/bugsnag/android/HttpClient;
|
||
|
.super Ljava/lang/Object;
|
||
|
.source "HttpClient.java"
|
||
|
|
||
|
|
||
|
# annotations
|
||
|
.annotation system Ldalvik/annotation/MemberClasses;
|
||
|
value = {
|
||
|
Lcom/bugsnag/android/HttpClient$NetworkException;,
|
||
|
Lcom/bugsnag/android/HttpClient$BadResponseException;
|
||
|
}
|
||
|
.end annotation
|
||
|
|
||
|
|
||
|
# direct methods
|
||
|
.method constructor <init>()V
|
||
|
.locals 0
|
||
|
|
||
|
.prologue
|
||
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||
|
|
||
|
return-void
|
||
|
.end method
|
||
|
|
||
|
.method static post(Ljava/lang/String;Lcom/bugsnag/android/JsonStream$Streamable;)V
|
||
|
.locals 9
|
||
|
.param p0, "urlString" # Ljava/lang/String;
|
||
|
.param p1, "payload" # Lcom/bugsnag/android/JsonStream$Streamable;
|
||
|
.annotation system Ldalvik/annotation/Throws;
|
||
|
value = {
|
||
|
Lcom/bugsnag/android/HttpClient$NetworkException;,
|
||
|
Lcom/bugsnag/android/HttpClient$BadResponseException;
|
||
|
}
|
||
|
.end annotation
|
||
|
|
||
|
.prologue
|
||
|
const/4 v1, 0x0
|
||
|
|
||
|
.local v1, "conn":Ljava/net/HttpURLConnection;
|
||
|
:try_start_0
|
||
|
new-instance v6, Ljava/net/URL;
|
||
|
|
||
|
invoke-direct {v6, p0}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
|
||
|
|
||
|
.local v6, "url":Ljava/net/URL;
|
||
|
invoke-virtual {v6}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;
|
||
|
|
||
|
move-result-object v7
|
||
|
|
||
|
move-object v0, v7
|
||
|
|
||
|
check-cast v0, Ljava/net/HttpURLConnection;
|
||
|
|
||
|
move-object v1, v0
|
||
|
|
||
|
const/4 v7, 0x1
|
||
|
|
||
|
invoke-virtual {v1, v7}, Ljava/net/HttpURLConnection;->setDoOutput(Z)V
|
||
|
|
||
|
const/4 v7, 0x0
|
||
|
|
||
|
invoke-virtual {v1, v7}, Ljava/net/HttpURLConnection;->setChunkedStreamingMode(I)V
|
||
|
|
||
|
const-string v7, "Content-Type"
|
||
|
|
||
|
const-string v8, "application/json"
|
||
|
|
||
|
invoke-virtual {v1, v7, v8}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
|
||
|
:try_end_0
|
||
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
||
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
||
|
|
||
|
const/4 v3, 0x0
|
||
|
|
||
|
.local v3, "out":Ljava/io/OutputStream;
|
||
|
:try_start_1
|
||
|
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getOutputStream()Ljava/io/OutputStream;
|
||
|
|
||
|
move-result-object v3
|
||
|
|
||
|
new-instance v5, Lcom/bugsnag/android/JsonStream;
|
||
|
|
||
|
new-instance v7, Ljava/io/OutputStreamWriter;
|
||
|
|
||
|
invoke-direct {v7, v3}, Ljava/io/OutputStreamWriter;-><init>(Ljava/io/OutputStream;)V
|
||
|
|
||
|
invoke-direct {v5, v7}, Lcom/bugsnag/android/JsonStream;-><init>(Ljava/io/Writer;)V
|
||
|
|
||
|
.local v5, "stream":Lcom/bugsnag/android/JsonStream;
|
||
|
invoke-interface {p1, v5}, Lcom/bugsnag/android/JsonStream$Streamable;->toStream(Lcom/bugsnag/android/JsonStream;)V
|
||
|
|
||
|
invoke-virtual {v5}, Lcom/bugsnag/android/JsonStream;->close()V
|
||
|
:try_end_1
|
||
|
.catchall {:try_start_1 .. :try_end_1} :catchall_1
|
||
|
|
||
|
:try_start_2
|
||
|
invoke-static {v3}, Lcom/bugsnag/android/IOUtils;->closeQuietly(Ljava/io/Closeable;)V
|
||
|
|
||
|
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getResponseCode()I
|
||
|
|
||
|
move-result v4
|
||
|
|
||
|
.local v4, "status":I
|
||
|
div-int/lit8 v7, v4, 0x64
|
||
|
|
||
|
const/4 v8, 0x2
|
||
|
|
||
|
if-eq v7, v8, :cond_0
|
||
|
|
||
|
new-instance v7, Lcom/bugsnag/android/HttpClient$BadResponseException;
|
||
|
|
||
|
invoke-direct {v7, p0, v4}, Lcom/bugsnag/android/HttpClient$BadResponseException;-><init>(Ljava/lang/String;I)V
|
||
|
|
||
|
throw v7
|
||
|
:try_end_2
|
||
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
|
||
|
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
||
|
|
||
|
.end local v3 # "out":Ljava/io/OutputStream;
|
||
|
.end local v4 # "status":I
|
||
|
.end local v5 # "stream":Lcom/bugsnag/android/JsonStream;
|
||
|
.end local v6 # "url":Ljava/net/URL;
|
||
|
:catch_0
|
||
|
move-exception v2
|
||
|
|
||
|
.local v2, "e":Ljava/io/IOException;
|
||
|
:try_start_3
|
||
|
new-instance v7, Lcom/bugsnag/android/HttpClient$NetworkException;
|
||
|
|
||
|
invoke-direct {v7, p0, v2}, Lcom/bugsnag/android/HttpClient$NetworkException;-><init>(Ljava/lang/String;Ljava/lang/Exception;)V
|
||
|
|
||
|
throw v7
|
||
|
:try_end_3
|
||
|
.catchall {:try_start_3 .. :try_end_3} :catchall_0
|
||
|
|
||
|
.end local v2 # "e":Ljava/io/IOException;
|
||
|
:catchall_0
|
||
|
move-exception v7
|
||
|
|
||
|
invoke-static {v1}, Lcom/bugsnag/android/IOUtils;->close(Ljava/net/URLConnection;)V
|
||
|
|
||
|
throw v7
|
||
|
|
||
|
.restart local v3 # "out":Ljava/io/OutputStream;
|
||
|
.restart local v6 # "url":Ljava/net/URL;
|
||
|
:catchall_1
|
||
|
move-exception v7
|
||
|
|
||
|
:try_start_4
|
||
|
invoke-static {v3}, Lcom/bugsnag/android/IOUtils;->closeQuietly(Ljava/io/Closeable;)V
|
||
|
|
||
|
throw v7
|
||
|
:try_end_4
|
||
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0
|
||
|
.catchall {:try_start_4 .. :try_end_4} :catchall_0
|
||
|
|
||
|
.restart local v4 # "status":I
|
||
|
.restart local v5 # "stream":Lcom/bugsnag/android/JsonStream;
|
||
|
:cond_0
|
||
|
invoke-static {v1}, Lcom/bugsnag/android/IOUtils;->close(Ljava/net/URLConnection;)V
|
||
|
|
||
|
return-void
|
||
|
.end method
|