Http1Codec$ChunkedSource.smali 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. .class Lokhttp3/internal/http1/Http1Codec$ChunkedSource;
  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 = "ChunkedSource"
  11. .end annotation
  12. # static fields
  13. .field private static final NO_CHUNK_YET:J = -0x1L
  14. # instance fields
  15. .field private bytesRemainingInChunk:J
  16. .field private hasMoreChunks:Z
  17. .field final synthetic this$0:Lokhttp3/internal/http1/Http1Codec;
  18. .field private final url:Lokhttp3/HttpUrl;
  19. # direct methods
  20. .method constructor <init>(Lokhttp3/internal/http1/Http1Codec;Lokhttp3/HttpUrl;)V
  21. .locals 2
  22. iput-object p1, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->this$0:Lokhttp3/internal/http1/Http1Codec;
  23. const/4 v0, 0x0
  24. invoke-direct {p0, p1, v0}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;-><init>(Lokhttp3/internal/http1/Http1Codec;Lokhttp3/internal/http1/Http1Codec$1;)V
  25. const-wide/16 v0, -0x1
  26. iput-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  27. const/4 p1, 0x1
  28. iput-boolean p1, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->hasMoreChunks:Z
  29. iput-object p2, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->url:Lokhttp3/HttpUrl;
  30. return-void
  31. .end method
  32. .method private readChunkSize()V
  33. .locals 6
  34. .annotation system Ldalvik/annotation/Throws;
  35. value = {
  36. Ljava/io/IOException;
  37. }
  38. .end annotation
  39. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  40. const-wide/16 v2, -0x1
  41. cmp-long v4, v0, v2
  42. if-eqz v4, :cond_0
  43. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->this$0:Lokhttp3/internal/http1/Http1Codec;
  44. iget-object v0, v0, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/BufferedSource;
  45. invoke-interface {v0}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  46. :cond_0
  47. :try_start_0
  48. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->this$0:Lokhttp3/internal/http1/Http1Codec;
  49. iget-object v0, v0, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/BufferedSource;
  50. invoke-interface {v0}, Lokio/BufferedSource;->readHexadecimalUnsignedLong()J
  51. move-result-wide v0
  52. iput-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  53. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->this$0:Lokhttp3/internal/http1/Http1Codec;
  54. iget-object v0, v0, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/BufferedSource;
  55. invoke-interface {v0}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  56. move-result-object v0
  57. invoke-virtual {v0}, Ljava/lang/String;->trim()Ljava/lang/String;
  58. move-result-object v0
  59. iget-wide v1, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  60. const-wide/16 v3, 0x0
  61. cmp-long v5, v1, v3
  62. if-ltz v5, :cond_3
  63. invoke-virtual {v0}, Ljava/lang/String;->isEmpty()Z
  64. move-result v1
  65. if-nez v1, :cond_1
  66. const-string v1, ";"
  67. invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  68. move-result v1
  69. :try_end_0
  70. .catch Ljava/lang/NumberFormatException; {:try_start_0 .. :try_end_0} :catch_0
  71. if-eqz v1, :cond_3
  72. :cond_1
  73. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  74. cmp-long v2, v0, v3
  75. if-nez v2, :cond_2
  76. const/4 v0, 0x0
  77. iput-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->hasMoreChunks:Z
  78. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->this$0:Lokhttp3/internal/http1/Http1Codec;
  79. iget-object v0, v0, Lokhttp3/internal/http1/Http1Codec;->client:Lokhttp3/OkHttpClient;
  80. invoke-virtual {v0}, Lokhttp3/OkHttpClient;->cookieJar()Lokhttp3/CookieJar;
  81. move-result-object v0
  82. iget-object v1, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->url:Lokhttp3/HttpUrl;
  83. iget-object v2, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->this$0:Lokhttp3/internal/http1/Http1Codec;
  84. invoke-virtual {v2}, Lokhttp3/internal/http1/Http1Codec;->readHeaders()Lokhttp3/Headers;
  85. move-result-object v2
  86. invoke-static {v0, v1, v2}, Lokhttp3/internal/http/HttpHeaders;->receiveHeaders(Lokhttp3/CookieJar;Lokhttp3/HttpUrl;Lokhttp3/Headers;)V
  87. const/4 v0, 0x1
  88. const/4 v1, 0x0
  89. invoke-virtual {p0, v0, v1}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V
  90. :cond_2
  91. return-void
  92. :cond_3
  93. :try_start_1
  94. new-instance v1, Ljava/net/ProtocolException;
  95. new-instance v2, Ljava/lang/StringBuilder;
  96. invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
  97. const-string v3, "expected chunk size and optional extensions but was \""
  98. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  99. iget-wide v3, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  100. invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
  101. invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  102. const-string v0, "\""
  103. invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  104. invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  105. move-result-object v0
  106. invoke-direct {v1, v0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  107. throw v1
  108. :try_end_1
  109. .catch Ljava/lang/NumberFormatException; {:try_start_1 .. :try_end_1} :catch_0
  110. :catch_0
  111. move-exception v0
  112. new-instance v1, Ljava/net/ProtocolException;
  113. invoke-virtual {v0}, Ljava/lang/NumberFormatException;->getMessage()Ljava/lang/String;
  114. move-result-object v0
  115. invoke-direct {v1, v0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  116. throw v1
  117. .end method
  118. # virtual methods
  119. .method public close()V
  120. .locals 2
  121. .annotation system Ldalvik/annotation/Throws;
  122. value = {
  123. Ljava/io/IOException;
  124. }
  125. .end annotation
  126. iget-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->closed:Z
  127. if-eqz v0, :cond_0
  128. return-void
  129. :cond_0
  130. iget-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->hasMoreChunks:Z
  131. if-eqz v0, :cond_1
  132. const/16 v0, 0x64
  133. sget-object v1, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
  134. invoke-static {p0, v0, v1}, Lokhttp3/internal/Util;->discard(Lokio/Source;ILjava/util/concurrent/TimeUnit;)Z
  135. move-result v0
  136. if-nez v0, :cond_1
  137. const/4 v0, 0x0
  138. const/4 v1, 0x0
  139. invoke-virtual {p0, v0, v1}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V
  140. :cond_1
  141. const/4 v0, 0x1
  142. iput-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->closed:Z
  143. return-void
  144. .end method
  145. .method public read(Lokio/Buffer;J)J
  146. .locals 7
  147. .annotation system Ldalvik/annotation/Throws;
  148. value = {
  149. Ljava/io/IOException;
  150. }
  151. .end annotation
  152. const-wide/16 v0, 0x0
  153. cmp-long v2, p2, v0
  154. if-ltz v2, :cond_5
  155. iget-boolean v2, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->closed:Z
  156. if-nez v2, :cond_4
  157. iget-boolean v2, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->hasMoreChunks:Z
  158. const-wide/16 v3, -0x1
  159. if-nez v2, :cond_0
  160. return-wide v3
  161. :cond_0
  162. iget-wide v5, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  163. cmp-long v2, v5, v0
  164. if-eqz v2, :cond_1
  165. cmp-long v0, v5, v3
  166. if-nez v0, :cond_2
  167. :cond_1
  168. invoke-direct {p0}, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->readChunkSize()V
  169. iget-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->hasMoreChunks:Z
  170. if-nez v0, :cond_2
  171. return-wide v3
  172. :cond_2
  173. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  174. invoke-static {p2, p3, v0, v1}, Ljava/lang/Math;->min(JJ)J
  175. move-result-wide p2
  176. invoke-super {p0, p1, p2, p3}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->read(Lokio/Buffer;J)J
  177. move-result-wide p1
  178. cmp-long p3, p1, v3
  179. if-eqz p3, :cond_3
  180. iget-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  181. sub-long/2addr v0, p1
  182. iput-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;->bytesRemainingInChunk:J
  183. return-wide p1
  184. :cond_3
  185. new-instance p1, Ljava/net/ProtocolException;
  186. const-string p2, "unexpected end of stream"
  187. invoke-direct {p1, p2}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  188. const/4 p2, 0x0
  189. invoke-virtual {p0, p2, p1}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V
  190. throw p1
  191. :cond_4
  192. new-instance p1, Ljava/lang/IllegalStateException;
  193. const-string p2, "closed"
  194. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  195. throw p1
  196. :cond_5
  197. new-instance p1, Ljava/lang/IllegalArgumentException;
  198. new-instance v0, Ljava/lang/StringBuilder;
  199. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  200. const-string v1, "byteCount < 0: "
  201. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  202. invoke-virtual {v0, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
  203. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  204. move-result-object p2
  205. invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  206. throw p1
  207. .end method