Http1Codec$FixedLengthSource.smali 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .class Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;
  2. .super Lokhttp3/internal/http1/Http1Codec$AbstractSource;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/internal/http1/Http1Codec;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x2
  10. name = "FixedLengthSource"
  11. .end annotation
  12. # instance fields
  13. .field private bytesRemaining:J
  14. .field final synthetic this$0:Lokhttp3/internal/http1/Http1Codec;
  15. # direct methods
  16. .method constructor <init>(Lokhttp3/internal/http1/Http1Codec;J)V
  17. .locals 3
  18. .annotation system Ldalvik/annotation/Throws;
  19. value = {
  20. Ljava/io/IOException;
  21. }
  22. .end annotation
  23. iput-object p1, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->this$0:Lokhttp3/internal/http1/Http1Codec;
  24. const/4 v0, 0x0
  25. invoke-direct {p0, p1, v0}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;-><init>(Lokhttp3/internal/http1/Http1Codec;Lokhttp3/internal/http1/Http1Codec$1;)V
  26. iput-wide p2, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->bytesRemaining:J
  27. iget-wide p1, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->bytesRemaining:J
  28. const-wide/16 v1, 0x0
  29. cmp-long p3, p1, v1
  30. if-nez p3, :cond_0
  31. const/4 p1, 0x1
  32. invoke-virtual {p0, p1, v0}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V
  33. :cond_0
  34. return-void
  35. .end method
  36. # virtual methods
  37. .method public close()V
  38. .locals 5
  39. .annotation system Ldalvik/annotation/Throws;
  40. value = {
  41. Ljava/io/IOException;
  42. }
  43. .end annotation
  44. iget-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->closed:Z
  45. if-eqz v0, :cond_0
  46. return-void
  47. :cond_0
  48. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->bytesRemaining:J
  49. const-wide/16 v2, 0x0
  50. cmp-long v4, v0, v2
  51. if-eqz v4, :cond_1
  52. const/16 v0, 0x64
  53. sget-object v1, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
  54. invoke-static {p0, v0, v1}, Lokhttp3/internal/Util;->discard(Lokio/Source;ILjava/util/concurrent/TimeUnit;)Z
  55. move-result v0
  56. if-nez v0, :cond_1
  57. const/4 v0, 0x0
  58. const/4 v1, 0x0
  59. invoke-virtual {p0, v0, v1}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V
  60. :cond_1
  61. const/4 v0, 0x1
  62. iput-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->closed:Z
  63. return-void
  64. .end method
  65. .method public read(Lokio/Buffer;J)J
  66. .locals 7
  67. .annotation system Ldalvik/annotation/Throws;
  68. value = {
  69. Ljava/io/IOException;
  70. }
  71. .end annotation
  72. const-wide/16 v0, 0x0
  73. cmp-long v2, p2, v0
  74. if-ltz v2, :cond_4
  75. iget-boolean v2, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->closed:Z
  76. if-nez v2, :cond_3
  77. iget-wide v2, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->bytesRemaining:J
  78. const-wide/16 v4, -0x1
  79. cmp-long v6, v2, v0
  80. if-nez v6, :cond_0
  81. return-wide v4
  82. :cond_0
  83. invoke-static {v2, v3, p2, p3}, Ljava/lang/Math;->min(JJ)J
  84. move-result-wide p2
  85. invoke-super {p0, p1, p2, p3}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->read(Lokio/Buffer;J)J
  86. move-result-wide p1
  87. cmp-long p3, p1, v4
  88. if-eqz p3, :cond_2
  89. iget-wide v2, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->bytesRemaining:J
  90. sub-long/2addr v2, p1
  91. iput-wide v2, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->bytesRemaining:J
  92. iget-wide v2, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;->bytesRemaining:J
  93. cmp-long p3, v2, v0
  94. if-nez p3, :cond_1
  95. const/4 p3, 0x1
  96. const/4 v0, 0x0
  97. invoke-virtual {p0, p3, v0}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V
  98. :cond_1
  99. return-wide p1
  100. :cond_2
  101. new-instance p1, Ljava/net/ProtocolException;
  102. const-string p2, "unexpected end of stream"
  103. invoke-direct {p1, p2}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  104. const/4 p2, 0x0
  105. invoke-virtual {p0, p2, p1}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V
  106. throw p1
  107. :cond_3
  108. new-instance p1, Ljava/lang/IllegalStateException;
  109. const-string p2, "closed"
  110. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  111. throw p1
  112. :cond_4
  113. new-instance p1, Ljava/lang/IllegalArgumentException;
  114. new-instance v0, Ljava/lang/StringBuilder;
  115. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  116. const-string v1, "byteCount < 0: "
  117. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  118. invoke-virtual {v0, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
  119. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  120. move-result-object p2
  121. invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  122. throw p1
  123. .end method