apkfuckery/com.discord/smali/okhttp3/internal/http/RetryableSink.smali
2019-02-04 21:05:16 +01:00

296 lines
6.7 KiB
Smali

.class public final Lokhttp3/internal/http/RetryableSink;
.super Ljava/lang/Object;
.source "RetryableSink.java"
# interfaces
.implements Lokio/Sink;
# instance fields
.field private closed:Z
.field private final content:Lokio/Buffer;
.field private final limit:I
# direct methods
.method public constructor <init>()V
.locals 1
.prologue
const/4 v0, -0x1
invoke-direct {p0, v0}, Lokhttp3/internal/http/RetryableSink;-><init>(I)V
return-void
.end method
.method public constructor <init>(I)V
.locals 1
.param p1, "limit" # I
.prologue
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
new-instance v0, Lokio/Buffer;
invoke-direct {v0}, Lokio/Buffer;-><init>()V
iput-object v0, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
iput p1, p0, Lokhttp3/internal/http/RetryableSink;->limit:I
return-void
.end method
# virtual methods
.method public close()V
.locals 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.prologue
iget-boolean v0, p0, Lokhttp3/internal/http/RetryableSink;->closed:Z
if-eqz v0, :cond_1
:cond_0
return-void
:cond_1
const/4 v0, 0x1
iput-boolean v0, p0, Lokhttp3/internal/http/RetryableSink;->closed:Z
iget-object v0, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v0
iget v2, p0, Lokhttp3/internal/http/RetryableSink;->limit:I
int-to-long v2, v2
cmp-long v0, v0, v2
if-gez v0, :cond_0
new-instance v0, Ljava/net/ProtocolException;
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
const-string v2, "content-length promised "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
iget v2, p0, Lokhttp3/internal/http/RetryableSink;->limit:I
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object v1
const-string v2, " bytes, but received "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
iget-object v2, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
invoke-virtual {v2}, Lokio/Buffer;->size()J
move-result-wide v2
invoke-virtual {v1, v2, v3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public contentLength()J
.locals 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.prologue
iget-object v0, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v0
return-wide v0
.end method
.method public flush()V
.locals 0
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.prologue
return-void
.end method
.method public timeout()Lokio/Timeout;
.locals 1
.prologue
sget-object v0, Lokio/Timeout;->NONE:Lokio/Timeout;
return-object v0
.end method
.method public write(Lokio/Buffer;J)V
.locals 6
.param p1, "source" # Lokio/Buffer;
.param p2, "byteCount" # J
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.prologue
iget-boolean v0, p0, Lokhttp3/internal/http/RetryableSink;->closed:Z
if-eqz v0, :cond_0
new-instance v0, Ljava/lang/IllegalStateException;
const-string v1, "closed"
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
:cond_0
invoke-virtual {p1}, Lokio/Buffer;->size()J
move-result-wide v0
const-wide/16 v2, 0x0
move-wide v4, p2
invoke-static/range {v0 .. v5}, Lokhttp3/internal/Util;->checkOffsetAndCount(JJJ)V
iget v0, p0, Lokhttp3/internal/http/RetryableSink;->limit:I
const/4 v1, -0x1
if-eq v0, v1, :cond_1
iget-object v0, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v0
iget v2, p0, Lokhttp3/internal/http/RetryableSink;->limit:I
int-to-long v2, v2
sub-long/2addr v2, p2
cmp-long v0, v0, v2
if-lez v0, :cond_1
new-instance v0, Ljava/net/ProtocolException;
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
const-string v2, "exceeded content-length limit of "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
iget v2, p0, Lokhttp3/internal/http/RetryableSink;->limit:I
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object v1
const-string v2, " bytes"
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
throw v0
:cond_1
iget-object v0, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
invoke-virtual {v0, p1, p2, p3}, Lokio/Buffer;->write(Lokio/Buffer;J)V
return-void
.end method
.method public writeToSocket(Lokio/Sink;)V
.locals 6
.param p1, "socketOut" # Lokio/Sink;
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.prologue
new-instance v1, Lokio/Buffer;
invoke-direct {v1}, Lokio/Buffer;-><init>()V
.local v1, "buffer":Lokio/Buffer;
iget-object v0, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
const-wide/16 v2, 0x0
iget-object v4, p0, Lokhttp3/internal/http/RetryableSink;->content:Lokio/Buffer;
invoke-virtual {v4}, Lokio/Buffer;->size()J
move-result-wide v4
invoke-virtual/range {v0 .. v5}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
invoke-virtual {v1}, Lokio/Buffer;->size()J
move-result-wide v2
invoke-interface {p1, v1, v2, v3}, Lokio/Sink;->write(Lokio/Buffer;J)V
return-void
.end method