.class public final Lokhttp3/internal/connection/Exchange$RequestBodySink; .super Lokio/ForwardingSink; .source "SourceFile" # annotations .annotation system Ldalvik/annotation/EnclosingClass; value = Lokhttp3/internal/connection/Exchange; .end annotation .annotation system Ldalvik/annotation/InnerClass; accessFlags = 0x11 name = "RequestBodySink" .end annotation # instance fields .field public bytesReceived:J .field public closed:Z .field public completed:Z .field public contentLength:J .field public final synthetic this$0:Lokhttp3/internal/connection/Exchange; # direct methods .method public constructor (Lokhttp3/internal/connection/Exchange;Lokio/Sink;J)V .locals 0 iput-object p1, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->this$0:Lokhttp3/internal/connection/Exchange; .line 220 invoke-direct {p0, p2}, Lokio/ForwardingSink;->(Lokio/Sink;)V iput-wide p3, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->contentLength:J return-void .end method .method private complete(Ljava/io/IOException;)Ljava/io/IOException; .locals 7 iget-boolean v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->completed:Z if-eqz v0, :cond_0 return-object p1 :cond_0 const/4 v0, 0x1 iput-boolean v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->completed:Z iget-object v1, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->this$0:Lokhttp3/internal/connection/Exchange; iget-wide v2, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->bytesReceived:J const/4 v4, 0x0 const/4 v5, 0x1 move-object v6, p1 .line 263 invoke-virtual/range {v1 .. v6}, Lokhttp3/internal/connection/Exchange;->bodyComplete(JZZLjava/io/IOException;)Ljava/io/IOException; move-result-object p1 return-object p1 .end method # virtual methods .method public close()V .locals 4 iget-boolean v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->closed:Z if-eqz v0, :cond_0 return-void :cond_0 const/4 v0, 0x1 iput-boolean v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->closed:Z iget-wide v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->contentLength:J const-wide/16 v2, -0x1 cmp-long v2, v0, v2 if-eqz v2, :cond_2 iget-wide v2, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->bytesReceived:J cmp-long v0, v2, v0 if-nez v0, :cond_1 goto :goto_0 .line 250 :cond_1 new-instance v0, Ljava/net/ProtocolException; const-string v1, "unexpected end of stream" invoke-direct {v0, v1}, Ljava/net/ProtocolException;->(Ljava/lang/String;)V throw v0 .line 253 :cond_2 :goto_0 :try_start_0 invoke-super {p0}, Lokio/ForwardingSink;->close()V const/4 v0, 0x0 .line 254 invoke-direct {p0, v0}, Lokhttp3/internal/connection/Exchange$RequestBodySink;->complete(Ljava/io/IOException;)Ljava/io/IOException; :try_end_0 .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 return-void :catch_0 move-exception v0 .line 256 invoke-direct {p0, v0}, Lokhttp3/internal/connection/Exchange$RequestBodySink;->complete(Ljava/io/IOException;)Ljava/io/IOException; move-result-object v0 throw v0 .end method .method public flush()V .locals 1 .line 240 :try_start_0 invoke-super {p0}, Lokio/ForwardingSink;->flush()V :try_end_0 .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 return-void :catch_0 move-exception v0 .line 242 invoke-direct {p0, v0}, Lokhttp3/internal/connection/Exchange$RequestBodySink;->complete(Ljava/io/IOException;)Ljava/io/IOException; move-result-object v0 throw v0 .end method .method public write(Lokio/Buffer;J)V .locals 4 iget-boolean v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->closed:Z if-nez v0, :cond_2 iget-wide v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->contentLength:J const-wide/16 v2, -0x1 cmp-long v2, v0, v2 if-eqz v2, :cond_1 iget-wide v2, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->bytesReceived:J add-long/2addr v2, p2 cmp-long v0, v2, v0 if-gtz v0, :cond_0 goto :goto_0 .line 227 :cond_0 new-instance p1, Ljava/net/ProtocolException; new-instance v0, Ljava/lang/StringBuilder; invoke-direct {v0}, Ljava/lang/StringBuilder;->()V const-string v1, "expected " invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; iget-wide v1, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->contentLength:J invoke-virtual {v0, v1, v2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder; const-string v1, " bytes but received " invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; iget-wide v1, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->bytesReceived:J add-long/2addr v1, p2 invoke-virtual {v0, v1, v2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder; invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object p2 invoke-direct {p1, p2}, Ljava/net/ProtocolException;->(Ljava/lang/String;)V throw p1 .line 231 :cond_1 :goto_0 :try_start_0 invoke-super {p0, p1, p2, p3}, Lokio/ForwardingSink;->write(Lokio/Buffer;J)V iget-wide v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->bytesReceived:J add-long/2addr v0, p2 iput-wide v0, p0, Lokhttp3/internal/connection/Exchange$RequestBodySink;->bytesReceived:J :try_end_0 .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 return-void :catch_0 move-exception p1 .line 234 invoke-direct {p0, p1}, Lokhttp3/internal/connection/Exchange$RequestBodySink;->complete(Ljava/io/IOException;)Ljava/io/IOException; move-result-object p1 throw p1 .line 225 :cond_2 new-instance p1, Ljava/lang/IllegalStateException; const-string p2, "closed" invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;->(Ljava/lang/String;)V throw p1 .end method