351 lines
7.3 KiB
Smali
351 lines
7.3 KiB
Smali
.class public final Lorg/apache/http/util/EntityUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "EntityUtils.java"
|
|
|
|
|
|
# direct methods
|
|
.method private constructor <init>()V
|
|
.locals 0
|
|
|
|
.line 1
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static getContentCharSet(Lorg/apache/http/HttpEntity;)Ljava/lang/String;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Lorg/apache/http/ParseException;
|
|
}
|
|
.end annotation
|
|
|
|
if-eqz p0, :cond_1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentType()Lorg/apache/http/Header;
|
|
|
|
move-result-object v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
.line 2
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentType()Lorg/apache/http/Header;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-interface {p0}, Lorg/apache/http/Header;->getElements()[Lorg/apache/http/HeaderElement;
|
|
|
|
move-result-object p0
|
|
|
|
.line 3
|
|
array-length v1, p0
|
|
|
|
if-lez v1, :cond_0
|
|
|
|
const/4 v1, 0x0
|
|
|
|
.line 4
|
|
aget-object p0, p0, v1
|
|
|
|
const-string v1, "charset"
|
|
|
|
invoke-interface {p0, v1}, Lorg/apache/http/HeaderElement;->getParameterByName(Ljava/lang/String;)Lorg/apache/http/NameValuePair;
|
|
|
|
move-result-object p0
|
|
|
|
if-eqz p0, :cond_0
|
|
|
|
.line 5
|
|
invoke-interface {p0}, Lorg/apache/http/NameValuePair;->getValue()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
:cond_0
|
|
return-object v0
|
|
|
|
.line 6
|
|
:cond_1
|
|
new-instance p0, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string v0, "HTTP entity may not be null"
|
|
|
|
invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
.end method
|
|
|
|
.method public static toByteArray(Lorg/apache/http/HttpEntity;)[B
|
|
.locals 6
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
if-eqz p0, :cond_4
|
|
|
|
.line 1
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContent()Ljava/io/InputStream;
|
|
|
|
move-result-object v0
|
|
|
|
const/4 v1, 0x0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
new-array p0, v1, [B
|
|
|
|
return-object p0
|
|
|
|
.line 2
|
|
:cond_0
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentLength()J
|
|
|
|
move-result-wide v2
|
|
|
|
const-wide/32 v4, 0x7fffffff
|
|
|
|
cmp-long v2, v2, v4
|
|
|
|
if-gtz v2, :cond_3
|
|
|
|
.line 3
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentLength()J
|
|
|
|
move-result-wide v2
|
|
|
|
long-to-int p0, v2
|
|
|
|
const/16 v2, 0x1000
|
|
|
|
if-gez p0, :cond_1
|
|
|
|
move p0, v2
|
|
|
|
.line 4
|
|
:cond_1
|
|
new-instance v3, Lorg/apache/http/util/ByteArrayBuffer;
|
|
|
|
invoke-direct {v3, p0}, Lorg/apache/http/util/ByteArrayBuffer;-><init>(I)V
|
|
|
|
:try_start_0
|
|
new-array p0, v2, [B
|
|
|
|
.line 5
|
|
:goto_0
|
|
invoke-virtual {v0, p0}, Ljava/io/InputStream;->read([B)I
|
|
|
|
move-result v2
|
|
|
|
const/4 v4, -0x1
|
|
|
|
if-eq v2, v4, :cond_2
|
|
|
|
.line 6
|
|
invoke-virtual {v3, p0, v1, v2}, Lorg/apache/http/util/ByteArrayBuffer;->append([BII)V
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
goto :goto_0
|
|
|
|
.line 7
|
|
:cond_2
|
|
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
|
|
|
|
.line 8
|
|
invoke-virtual {v3}, Lorg/apache/http/util/ByteArrayBuffer;->toByteArray()[B
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
.line 9
|
|
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
|
|
|
|
throw p0
|
|
|
|
.line 10
|
|
:cond_3
|
|
new-instance p0, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string v0, "HTTP entity too large to be buffered in memory"
|
|
|
|
invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
|
|
.line 11
|
|
:cond_4
|
|
new-instance p0, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string v0, "HTTP entity may not be null"
|
|
|
|
invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
.end method
|
|
|
|
.method public static toString(Lorg/apache/http/HttpEntity;)Ljava/lang/String;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;,
|
|
Lorg/apache/http/ParseException;
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 14
|
|
invoke-static {p0, v0}, Lorg/apache/http/util/EntityUtils;->toString(Lorg/apache/http/HttpEntity;Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static toString(Lorg/apache/http/HttpEntity;Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 5
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;,
|
|
Lorg/apache/http/ParseException;
|
|
}
|
|
.end annotation
|
|
|
|
if-eqz p0, :cond_6
|
|
|
|
.line 1
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContent()Ljava/io/InputStream;
|
|
|
|
move-result-object v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
const-string p0, ""
|
|
|
|
return-object p0
|
|
|
|
.line 2
|
|
:cond_0
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentLength()J
|
|
|
|
move-result-wide v1
|
|
|
|
const-wide/32 v3, 0x7fffffff
|
|
|
|
cmp-long v1, v1, v3
|
|
|
|
if-gtz v1, :cond_5
|
|
|
|
.line 3
|
|
invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentLength()J
|
|
|
|
move-result-wide v1
|
|
|
|
long-to-int v1, v1
|
|
|
|
if-gez v1, :cond_1
|
|
|
|
const/16 v1, 0x1000
|
|
|
|
.line 4
|
|
:cond_1
|
|
invoke-static {p0}, Lorg/apache/http/util/EntityUtils;->getContentCharSet(Lorg/apache/http/HttpEntity;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
if-nez p0, :cond_2
|
|
|
|
goto :goto_0
|
|
|
|
:cond_2
|
|
move-object p1, p0
|
|
|
|
:goto_0
|
|
if-nez p1, :cond_3
|
|
|
|
const-string p1, "ISO-8859-1"
|
|
|
|
.line 5
|
|
:cond_3
|
|
new-instance p0, Ljava/io/InputStreamReader;
|
|
|
|
invoke-direct {p0, v0, p1}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;Ljava/lang/String;)V
|
|
|
|
.line 6
|
|
new-instance p1, Lorg/apache/http/util/CharArrayBuffer;
|
|
|
|
invoke-direct {p1, v1}, Lorg/apache/http/util/CharArrayBuffer;-><init>(I)V
|
|
|
|
const/16 v0, 0x400
|
|
|
|
:try_start_0
|
|
new-array v0, v0, [C
|
|
|
|
.line 7
|
|
:goto_1
|
|
invoke-virtual {p0, v0}, Ljava/io/Reader;->read([C)I
|
|
|
|
move-result v1
|
|
|
|
const/4 v2, -0x1
|
|
|
|
if-eq v1, v2, :cond_4
|
|
|
|
const/4 v2, 0x0
|
|
|
|
.line 8
|
|
invoke-virtual {p1, v0, v2, v1}, Lorg/apache/http/util/CharArrayBuffer;->append([CII)V
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
goto :goto_1
|
|
|
|
.line 9
|
|
:cond_4
|
|
invoke-virtual {p0}, Ljava/io/Reader;->close()V
|
|
|
|
.line 10
|
|
invoke-virtual {p1}, Lorg/apache/http/util/CharArrayBuffer;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
.line 11
|
|
invoke-virtual {p0}, Ljava/io/Reader;->close()V
|
|
|
|
throw p1
|
|
|
|
.line 12
|
|
:cond_5
|
|
new-instance p0, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string p1, "HTTP entity too large to be buffered in memory"
|
|
|
|
invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
|
|
.line 13
|
|
:cond_6
|
|
new-instance p0, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string p1, "HTTP entity may not be null"
|
|
|
|
invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
.end method
|