Http1Codec$FixedLengthSink.smali 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. .class final Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Lokio/Sink;
  6. # annotations
  7. .annotation system Ldalvik/annotation/EnclosingClass;
  8. value = Lokhttp3/internal/http1/Http1Codec;
  9. .end annotation
  10. .annotation system Ldalvik/annotation/InnerClass;
  11. accessFlags = 0x12
  12. name = "FixedLengthSink"
  13. .end annotation
  14. # instance fields
  15. .field private bytesRemaining:J
  16. .field private closed:Z
  17. .field final synthetic this$0:Lokhttp3/internal/http1/Http1Codec;
  18. .field private final timeout:Lokio/ForwardingTimeout;
  19. # direct methods
  20. .method constructor <init>(Lokhttp3/internal/http1/Http1Codec;J)V
  21. .locals 1
  22. iput-object p1, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->this$0:Lokhttp3/internal/http1/Http1Codec;
  23. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  24. new-instance p1, Lokio/ForwardingTimeout;
  25. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->this$0:Lokhttp3/internal/http1/Http1Codec;
  26. iget-object v0, v0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  27. invoke-interface {v0}, Lokio/Sink;->timeout()Lokio/Timeout;
  28. move-result-object v0
  29. invoke-direct {p1, v0}, Lokio/ForwardingTimeout;-><init>(Lokio/Timeout;)V
  30. iput-object p1, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->timeout:Lokio/ForwardingTimeout;
  31. iput-wide p2, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->bytesRemaining:J
  32. return-void
  33. .end method
  34. # virtual methods
  35. .method public close()V
  36. .locals 5
  37. .annotation system Ldalvik/annotation/Throws;
  38. value = {
  39. Ljava/io/IOException;
  40. }
  41. .end annotation
  42. iget-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->closed:Z
  43. if-eqz v0, :cond_0
  44. return-void
  45. :cond_0
  46. const/4 v0, 0x1
  47. iput-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->closed:Z
  48. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->bytesRemaining:J
  49. const-wide/16 v2, 0x0
  50. cmp-long v4, v0, v2
  51. if-gtz v4, :cond_1
  52. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->this$0:Lokhttp3/internal/http1/Http1Codec;
  53. iget-object v1, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->timeout:Lokio/ForwardingTimeout;
  54. invoke-virtual {v0, v1}, Lokhttp3/internal/http1/Http1Codec;->detachTimeout(Lokio/ForwardingTimeout;)V
  55. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->this$0:Lokhttp3/internal/http1/Http1Codec;
  56. const/4 v1, 0x3
  57. iput v1, v0, Lokhttp3/internal/http1/Http1Codec;->state:I
  58. return-void
  59. :cond_1
  60. new-instance v0, Ljava/net/ProtocolException;
  61. const-string v1, "unexpected end of stream"
  62. invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  63. throw v0
  64. .end method
  65. .method public flush()V
  66. .locals 1
  67. .annotation system Ldalvik/annotation/Throws;
  68. value = {
  69. Ljava/io/IOException;
  70. }
  71. .end annotation
  72. iget-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->closed:Z
  73. if-eqz v0, :cond_0
  74. return-void
  75. :cond_0
  76. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->this$0:Lokhttp3/internal/http1/Http1Codec;
  77. iget-object v0, v0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  78. invoke-interface {v0}, Lokio/BufferedSink;->flush()V
  79. return-void
  80. .end method
  81. .method public timeout()Lokio/Timeout;
  82. .locals 1
  83. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->timeout:Lokio/ForwardingTimeout;
  84. return-object v0
  85. .end method
  86. .method public write(Lokio/Buffer;J)V
  87. .locals 7
  88. .annotation system Ldalvik/annotation/Throws;
  89. value = {
  90. Ljava/io/IOException;
  91. }
  92. .end annotation
  93. iget-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->closed:Z
  94. if-nez v0, :cond_1
  95. invoke-virtual {p1}, Lokio/Buffer;->size()J
  96. move-result-wide v1
  97. const-wide/16 v3, 0x0
  98. move-wide v5, p2
  99. invoke-static/range {v1 .. v6}, Lokhttp3/internal/Util;->checkOffsetAndCount(JJJ)V
  100. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->bytesRemaining:J
  101. cmp-long v2, p2, v0
  102. if-gtz v2, :cond_0
  103. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->this$0:Lokhttp3/internal/http1/Http1Codec;
  104. iget-object v0, v0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  105. invoke-interface {v0, p1, p2, p3}, Lokio/Sink;->write(Lokio/Buffer;J)V
  106. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->bytesRemaining:J
  107. sub-long/2addr v0, p2
  108. iput-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->bytesRemaining:J
  109. return-void
  110. :cond_0
  111. new-instance p1, Ljava/net/ProtocolException;
  112. new-instance v0, Ljava/lang/StringBuilder;
  113. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  114. const-string v1, "expected "
  115. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  116. iget-wide v1, p0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;->bytesRemaining:J
  117. invoke-virtual {v0, v1, v2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
  118. const-string v1, " bytes but received "
  119. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  120. invoke-virtual {v0, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
  121. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  122. move-result-object p2
  123. invoke-direct {p1, p2}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  124. throw p1
  125. :cond_1
  126. new-instance p1, Ljava/lang/IllegalStateException;
  127. const-string p2, "closed"
  128. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  129. throw p1
  130. .end method