.class public final Lokhttp3/internal/connection/Exchange$ResponseBodySource; .super Lokio/ForwardingSource; .source "SourceFile" # annotations .annotation system Ldalvik/annotation/EnclosingClass; value = Lokhttp3/internal/connection/Exchange; .end annotation .annotation system Ldalvik/annotation/InnerClass; accessFlags = 0x11 name = "ResponseBodySource" .end annotation # instance fields .field public bytesReceived:J .field public closed:Z .field public completed:Z .field public final contentLength:J .field public final synthetic this$0:Lokhttp3/internal/connection/Exchange; # direct methods .method public constructor (Lokhttp3/internal/connection/Exchange;Lokio/Source;J)V .locals 0 iput-object p1, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->this$0:Lokhttp3/internal/connection/Exchange; .line 275 invoke-direct {p0, p2}, Lokio/ForwardingSource;->(Lokio/Source;)V iput-wide p3, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->contentLength:J const-wide/16 p1, 0x0 cmp-long p1, p3, p1 if-nez p1, :cond_0 const/4 p1, 0x0 .line 279 invoke-virtual {p0, p1}, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->complete(Ljava/io/IOException;)Ljava/io/IOException; :cond_0 return-void .end method # virtual methods .method public close()V .locals 1 iget-boolean v0, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->closed:Z if-eqz v0, :cond_0 return-void :cond_0 const/4 v0, 0x1 iput-boolean v0, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->closed:Z .line 313 :try_start_0 invoke-super {p0}, Lokio/ForwardingSource;->close()V const/4 v0, 0x0 .line 314 invoke-virtual {p0, v0}, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->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 316 invoke-virtual {p0, v0}, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->complete(Ljava/io/IOException;)Ljava/io/IOException; move-result-object v0 throw v0 .end method .method public complete(Ljava/io/IOException;)Ljava/io/IOException; .locals 7 iget-boolean v0, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->completed:Z if-eqz v0, :cond_0 return-object p1 :cond_0 const/4 v0, 0x1 iput-boolean v0, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->completed:Z iget-object v1, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->this$0:Lokhttp3/internal/connection/Exchange; iget-wide v2, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->bytesReceived:J const/4 v4, 0x1 const/4 v5, 0x0 move-object v6, p1 .line 323 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 .method public read(Lokio/Buffer;J)J .locals 7 iget-boolean v0, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->closed:Z if-nez v0, :cond_4 .line 286 :try_start_0 invoke-virtual {p0}, Lokio/ForwardingSource;->delegate()Lokio/Source; move-result-object v0 invoke-interface {v0, p1, p2, p3}, Lokio/Source;->read(Lokio/Buffer;J)J move-result-wide p1 const-wide/16 v0, -0x1 cmp-long p3, p1, v0 const/4 v2, 0x0 if-nez p3, :cond_0 .line 288 invoke-virtual {p0, v2}, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->complete(Ljava/io/IOException;)Ljava/io/IOException; return-wide v0 :catch_0 move-exception p1 goto :goto_1 :cond_0 iget-wide v3, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->bytesReceived:J add-long/2addr v3, p1 iget-wide v5, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->contentLength:J cmp-long p3, v5, v0 if-eqz p3, :cond_2 cmp-long p3, v3, v5 if-gtz p3, :cond_1 goto :goto_0 .line 294 :cond_1 new-instance p1, Ljava/net/ProtocolException; new-instance p2, Ljava/lang/StringBuilder; invoke-direct {p2}, Ljava/lang/StringBuilder;->()V const-string p3, "expected " invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; iget-wide v0, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->contentLength:J invoke-virtual {p2, v0, v1}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder; const-string p3, " bytes but received " invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; invoke-virtual {p2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder; invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object p2 invoke-direct {p1, p2}, Ljava/net/ProtocolException;->(Ljava/lang/String;)V throw p1 :cond_2 :goto_0 iput-wide v3, p0, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->bytesReceived:J cmp-long p3, v3, v5 if-nez p3, :cond_3 .line 300 invoke-virtual {p0, v2}, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->complete(Ljava/io/IOException;)Ljava/io/IOException; :try_end_0 .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 :cond_3 return-wide p1 .line 305 :goto_1 invoke-virtual {p0, p1}, Lokhttp3/internal/connection/Exchange$ResponseBodySource;->complete(Ljava/io/IOException;)Ljava/io/IOException; move-result-object p1 throw p1 .line 284 :cond_4 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