2022-06-10 21:38:30 +09:00

765 lines
19 KiB
Smali

.class public final Lcom/google/api/client/http/HttpResponse;
.super Ljava/lang/Object;
.source "HttpResponse.java"
# instance fields
.field private content:Ljava/io/InputStream;
.field private final contentEncoding:Ljava/lang/String;
.field private contentLoggingLimit:I
.field private contentRead:Z
.field private final contentType:Ljava/lang/String;
.field private loggingEnabled:Z
.field private final mediaType:Lcom/google/api/client/http/HttpMediaType;
.field private final request:Lcom/google/api/client/http/HttpRequest;
.field public response:Lcom/google/api/client/http/LowLevelHttpResponse;
.field private final statusCode:I
.field private final statusMessage:Ljava/lang/String;
# direct methods
.method public constructor <init>(Lcom/google/api/client/http/HttpRequest;Lcom/google/api/client/http/LowLevelHttpResponse;)V
.locals 8
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 2
iput-object p1, p0, Lcom/google/api/client/http/HttpResponse;->request:Lcom/google/api/client/http/HttpRequest;
.line 3
invoke-virtual {p1}, Lcom/google/api/client/http/HttpRequest;->getContentLoggingLimit()I
move-result v0
iput v0, p0, Lcom/google/api/client/http/HttpResponse;->contentLoggingLimit:I
.line 4
invoke-virtual {p1}, Lcom/google/api/client/http/HttpRequest;->isLoggingEnabled()Z
move-result v0
iput-boolean v0, p0, Lcom/google/api/client/http/HttpResponse;->loggingEnabled:Z
.line 5
iput-object p2, p0, Lcom/google/api/client/http/HttpResponse;->response:Lcom/google/api/client/http/LowLevelHttpResponse;
.line 6
invoke-virtual {p2}, Lcom/google/api/client/http/LowLevelHttpResponse;->getContentEncoding()Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/google/api/client/http/HttpResponse;->contentEncoding:Ljava/lang/String;
.line 7
invoke-virtual {p2}, Lcom/google/api/client/http/LowLevelHttpResponse;->getStatusCode()I
move-result v0
const/4 v1, 0x0
if-gez v0, :cond_0
move v0, v1
.line 8
:cond_0
iput v0, p0, Lcom/google/api/client/http/HttpResponse;->statusCode:I
.line 9
invoke-virtual {p2}, Lcom/google/api/client/http/LowLevelHttpResponse;->getReasonPhrase()Ljava/lang/String;
move-result-object v2
.line 10
iput-object v2, p0, Lcom/google/api/client/http/HttpResponse;->statusMessage:Ljava/lang/String;
.line 11
sget-object v3, Lcom/google/api/client/http/HttpTransport;->LOGGER:Ljava/util/logging/Logger;
.line 12
iget-boolean v4, p0, Lcom/google/api/client/http/HttpResponse;->loggingEnabled:Z
if-eqz v4, :cond_1
sget-object v4, Ljava/util/logging/Level;->CONFIG:Ljava/util/logging/Level;
invoke-virtual {v3, v4}, Ljava/util/logging/Logger;->isLoggable(Ljava/util/logging/Level;)Z
move-result v4
if-eqz v4, :cond_1
const/4 v1, 0x1
:cond_1
const/4 v4, 0x0
if-eqz v1, :cond_4
const-string v5, "-------------- RESPONSE --------------"
.line 13
invoke-static {v5}, Landroid/support/v4/media/d;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v5
.line 14
sget-object v6, Lcom/google/api/client/util/StringUtils;->LINE_SEPARATOR:Ljava/lang/String;
invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 15
invoke-virtual {p2}, Lcom/google/api/client/http/LowLevelHttpResponse;->getStatusLine()Ljava/lang/String;
move-result-object v7
if-eqz v7, :cond_2
.line 16
invoke-virtual {v5, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
goto :goto_0
.line 17
:cond_2
invoke-virtual {v5, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
if-eqz v2, :cond_3
const/16 v0, 0x20
.line 18
invoke-virtual {v5, v0}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 19
:cond_3
:goto_0
invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
goto :goto_1
:cond_4
move-object v5, v4
.line 20
:goto_1
invoke-virtual {p1}, Lcom/google/api/client/http/HttpRequest;->getResponseHeaders()Lcom/google/api/client/http/HttpHeaders;
move-result-object v0
if-eqz v1, :cond_5
move-object v2, v5
goto :goto_2
:cond_5
move-object v2, v4
:goto_2
invoke-virtual {v0, p2, v2}, Lcom/google/api/client/http/HttpHeaders;->fromHttpResponse(Lcom/google/api/client/http/LowLevelHttpResponse;Ljava/lang/StringBuilder;)V
.line 21
invoke-virtual {p2}, Lcom/google/api/client/http/LowLevelHttpResponse;->getContentType()Ljava/lang/String;
move-result-object p2
if-nez p2, :cond_6
.line 22
invoke-virtual {p1}, Lcom/google/api/client/http/HttpRequest;->getResponseHeaders()Lcom/google/api/client/http/HttpHeaders;
move-result-object p1
invoke-virtual {p1}, Lcom/google/api/client/http/HttpHeaders;->getContentType()Ljava/lang/String;
move-result-object p2
.line 23
:cond_6
iput-object p2, p0, Lcom/google/api/client/http/HttpResponse;->contentType:Ljava/lang/String;
if-nez p2, :cond_7
goto :goto_3
.line 24
:cond_7
new-instance v4, Lcom/google/api/client/http/HttpMediaType;
invoke-direct {v4, p2}, Lcom/google/api/client/http/HttpMediaType;-><init>(Ljava/lang/String;)V
:goto_3
iput-object v4, p0, Lcom/google/api/client/http/HttpResponse;->mediaType:Lcom/google/api/client/http/HttpMediaType;
if-eqz v1, :cond_8
.line 25
invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-virtual {v3, p1}, Ljava/util/logging/Logger;->config(Ljava/lang/String;)V
:cond_8
return-void
.end method
.method private hasMessageBody()Z
.locals 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getStatusCode()I
move-result v0
.line 2
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getRequest()Lcom/google/api/client/http/HttpRequest;
move-result-object v1
invoke-virtual {v1}, Lcom/google/api/client/http/HttpRequest;->getRequestMethod()Ljava/lang/String;
move-result-object v1
const-string v2, "HEAD"
invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v1
if-nez v1, :cond_1
div-int/lit8 v1, v0, 0x64
const/4 v2, 0x1
if-eq v1, v2, :cond_1
const/16 v1, 0xcc
if-eq v0, v1, :cond_1
const/16 v1, 0x130
if-ne v0, v1, :cond_0
goto :goto_0
:cond_0
return v2
.line 3
:cond_1
:goto_0
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->ignore()V
const/4 v0, 0x0
return v0
.end method
# virtual methods
.method public disconnect()V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->ignore()V
.line 2
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->response:Lcom/google/api/client/http/LowLevelHttpResponse;
invoke-virtual {v0}, Lcom/google/api/client/http/LowLevelHttpResponse;->disconnect()V
return-void
.end method
.method public download(Ljava/io/OutputStream;)V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContent()Ljava/io/InputStream;
move-result-object v0
.line 2
invoke-static {v0, p1}, Lcom/google/api/client/util/IOUtils;->copy(Ljava/io/InputStream;Ljava/io/OutputStream;)V
return-void
.end method
.method public getContent()Ljava/io/InputStream;
.locals 5
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
iget-boolean v0, p0, Lcom/google/api/client/http/HttpResponse;->contentRead:Z
if-nez v0, :cond_3
.line 2
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->response:Lcom/google/api/client/http/LowLevelHttpResponse;
invoke-virtual {v0}, Lcom/google/api/client/http/LowLevelHttpResponse;->getContent()Ljava/io/InputStream;
move-result-object v0
if-eqz v0, :cond_2
.line 3
:try_start_0
iget-object v1, p0, Lcom/google/api/client/http/HttpResponse;->contentEncoding:Ljava/lang/String;
if-eqz v1, :cond_0
const-string v2, "gzip"
.line 4
invoke-virtual {v1, v2}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
move-result v1
if-eqz v1, :cond_0
.line 5
new-instance v1, Ljava/util/zip/GZIPInputStream;
invoke-direct {v1, v0}, Ljava/util/zip/GZIPInputStream;-><init>(Ljava/io/InputStream;)V
move-object v0, v1
.line 6
:cond_0
sget-object v1, Lcom/google/api/client/http/HttpTransport;->LOGGER:Ljava/util/logging/Logger;
.line 7
iget-boolean v2, p0, Lcom/google/api/client/http/HttpResponse;->loggingEnabled:Z
if-eqz v2, :cond_1
sget-object v2, Ljava/util/logging/Level;->CONFIG:Ljava/util/logging/Level;
invoke-virtual {v1, v2}, Ljava/util/logging/Logger;->isLoggable(Ljava/util/logging/Level;)Z
move-result v3
if-eqz v3, :cond_1
.line 8
new-instance v3, Lcom/google/api/client/util/LoggingInputStream;
iget v4, p0, Lcom/google/api/client/http/HttpResponse;->contentLoggingLimit:I
invoke-direct {v3, v0, v1, v2, v4}, Lcom/google/api/client/util/LoggingInputStream;-><init>(Ljava/io/InputStream;Ljava/util/logging/Logger;Ljava/util/logging/Level;I)V
move-object v0, v3
.line 9
:cond_1
iput-object v0, p0, Lcom/google/api/client/http/HttpResponse;->content:Ljava/io/InputStream;
:try_end_0
.catch Ljava/io/EOFException; {:try_start_0 .. :try_end_0} :catch_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
goto :goto_0
:catchall_0
move-exception v1
.line 10
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
throw v1
:catch_0
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
:cond_2
:goto_0
const/4 v0, 0x1
.line 11
iput-boolean v0, p0, Lcom/google/api/client/http/HttpResponse;->contentRead:Z
.line 12
:cond_3
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->content:Ljava/io/InputStream;
return-object v0
.end method
.method public getContentCharset()Ljava/nio/charset/Charset;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->mediaType:Lcom/google/api/client/http/HttpMediaType;
if-eqz v0, :cond_1
invoke-virtual {v0}, Lcom/google/api/client/http/HttpMediaType;->getCharsetParameter()Ljava/nio/charset/Charset;
move-result-object v0
if-nez v0, :cond_0
goto :goto_0
:cond_0
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->mediaType:Lcom/google/api/client/http/HttpMediaType;
invoke-virtual {v0}, Lcom/google/api/client/http/HttpMediaType;->getCharsetParameter()Ljava/nio/charset/Charset;
move-result-object v0
goto :goto_1
:cond_1
:goto_0
sget-object v0, Lcom/google/api/client/util/Charsets;->ISO_8859_1:Ljava/nio/charset/Charset;
:goto_1
return-object v0
.end method
.method public getContentEncoding()Ljava/lang/String;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->contentEncoding:Ljava/lang/String;
return-object v0
.end method
.method public getContentLoggingLimit()I
.locals 1
.line 1
iget v0, p0, Lcom/google/api/client/http/HttpResponse;->contentLoggingLimit:I
return v0
.end method
.method public getContentType()Ljava/lang/String;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->contentType:Ljava/lang/String;
return-object v0
.end method
.method public getHeaders()Lcom/google/api/client/http/HttpHeaders;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->request:Lcom/google/api/client/http/HttpRequest;
invoke-virtual {v0}, Lcom/google/api/client/http/HttpRequest;->getResponseHeaders()Lcom/google/api/client/http/HttpHeaders;
move-result-object v0
return-object v0
.end method
.method public getMediaType()Lcom/google/api/client/http/HttpMediaType;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->mediaType:Lcom/google/api/client/http/HttpMediaType;
return-object v0
.end method
.method public getRequest()Lcom/google/api/client/http/HttpRequest;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->request:Lcom/google/api/client/http/HttpRequest;
return-object v0
.end method
.method public getStatusCode()I
.locals 1
.line 1
iget v0, p0, Lcom/google/api/client/http/HttpResponse;->statusCode:I
return v0
.end method
.method public getStatusMessage()Ljava/lang/String;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->statusMessage:Ljava/lang/String;
return-object v0
.end method
.method public getTransport()Lcom/google/api/client/http/HttpTransport;
.locals 1
.line 1
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->request:Lcom/google/api/client/http/HttpRequest;
invoke-virtual {v0}, Lcom/google/api/client/http/HttpRequest;->getTransport()Lcom/google/api/client/http/HttpTransport;
move-result-object v0
return-object v0
.end method
.method public ignore()V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContent()Ljava/io/InputStream;
move-result-object v0
if-eqz v0, :cond_0
.line 2
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
:cond_0
return-void
.end method
.method public isLoggingEnabled()Z
.locals 1
.line 1
iget-boolean v0, p0, Lcom/google/api/client/http/HttpResponse;->loggingEnabled:Z
return v0
.end method
.method public isSuccessStatusCode()Z
.locals 1
.line 1
iget v0, p0, Lcom/google/api/client/http/HttpResponse;->statusCode:I
invoke-static {v0}, Lcom/google/api/client/http/HttpStatusCodes;->isSuccess(I)Z
move-result v0
return v0
.end method
.method public parseAs(Ljava/lang/Class;)Ljava/lang/Object;
.locals 3
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Ljava/lang/Class<",
"TT;>;)TT;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-direct {p0}, Lcom/google/api/client/http/HttpResponse;->hasMessageBody()Z
move-result v0
if-nez v0, :cond_0
const/4 p1, 0x0
return-object p1
.line 2
:cond_0
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->request:Lcom/google/api/client/http/HttpRequest;
invoke-virtual {v0}, Lcom/google/api/client/http/HttpRequest;->getParser()Lcom/google/api/client/util/ObjectParser;
move-result-object v0
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContent()Ljava/io/InputStream;
move-result-object v1
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContentCharset()Ljava/nio/charset/Charset;
move-result-object v2
invoke-interface {v0, v1, v2, p1}, Lcom/google/api/client/util/ObjectParser;->parseAndClose(Ljava/io/InputStream;Ljava/nio/charset/Charset;Ljava/lang/Class;)Ljava/lang/Object;
move-result-object p1
return-object p1
.end method
.method public parseAs(Ljava/lang/reflect/Type;)Ljava/lang/Object;
.locals 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 3
invoke-direct {p0}, Lcom/google/api/client/http/HttpResponse;->hasMessageBody()Z
move-result v0
if-nez v0, :cond_0
const/4 p1, 0x0
return-object p1
.line 4
:cond_0
iget-object v0, p0, Lcom/google/api/client/http/HttpResponse;->request:Lcom/google/api/client/http/HttpRequest;
invoke-virtual {v0}, Lcom/google/api/client/http/HttpRequest;->getParser()Lcom/google/api/client/util/ObjectParser;
move-result-object v0
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContent()Ljava/io/InputStream;
move-result-object v1
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContentCharset()Ljava/nio/charset/Charset;
move-result-object v2
invoke-interface {v0, v1, v2, p1}, Lcom/google/api/client/util/ObjectParser;->parseAndClose(Ljava/io/InputStream;Ljava/nio/charset/Charset;Ljava/lang/reflect/Type;)Ljava/lang/Object;
move-result-object p1
return-object p1
.end method
.method public parseAsString()Ljava/lang/String;
.locals 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContent()Ljava/io/InputStream;
move-result-object v0
if-nez v0, :cond_0
const-string v0, ""
return-object v0
.line 2
:cond_0
new-instance v1, Ljava/io/ByteArrayOutputStream;
invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V
.line 3
invoke-static {v0, v1}, Lcom/google/api/client/util/IOUtils;->copy(Ljava/io/InputStream;Ljava/io/OutputStream;)V
.line 4
invoke-virtual {p0}, Lcom/google/api/client/http/HttpResponse;->getContentCharset()Ljava/nio/charset/Charset;
move-result-object v0
invoke-virtual {v0}, Ljava/nio/charset/Charset;->name()Ljava/lang/String;
move-result-object v0
invoke-virtual {v1, v0}, Ljava/io/ByteArrayOutputStream;->toString(Ljava/lang/String;)Ljava/lang/String;
move-result-object v0
return-object v0
.end method
.method public setContentLoggingLimit(I)Lcom/google/api/client/http/HttpResponse;
.locals 2
if-ltz p1, :cond_0
const/4 v0, 0x1
goto :goto_0
:cond_0
const/4 v0, 0x0
:goto_0
const-string v1, "The content logging limit must be non-negative."
.line 1
invoke-static {v0, v1}, Lcom/google/api/client/util/Preconditions;->checkArgument(ZLjava/lang/Object;)V
.line 2
iput p1, p0, Lcom/google/api/client/http/HttpResponse;->contentLoggingLimit:I
return-object p0
.end method
.method public setLoggingEnabled(Z)Lcom/google/api/client/http/HttpResponse;
.locals 0
.line 1
iput-boolean p1, p0, Lcom/google/api/client/http/HttpResponse;->loggingEnabled:Z
return-object p0
.end method