Http2Reader.smali 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  1. .class final Lokhttp3/internal/http2/Http2Reader;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Ljava/io/Closeable;
  6. # annotations
  7. .annotation system Ldalvik/annotation/MemberClasses;
  8. value = {
  9. Lokhttp3/internal/http2/Http2Reader$Handler;,
  10. Lokhttp3/internal/http2/Http2Reader$ContinuationSource;
  11. }
  12. .end annotation
  13. # static fields
  14. .field static final logger:Ljava/util/logging/Logger;
  15. # instance fields
  16. .field private final client:Z
  17. .field private final continuation:Lokhttp3/internal/http2/Http2Reader$ContinuationSource;
  18. .field final hpackReader:Lokhttp3/internal/http2/Hpack$Reader;
  19. .field private final source:Lokio/BufferedSource;
  20. # direct methods
  21. .method static constructor <clinit>()V
  22. .locals 1
  23. const-class v0, Lokhttp3/internal/http2/Http2;
  24. invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
  25. move-result-object v0
  26. invoke-static {v0}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
  27. move-result-object v0
  28. sput-object v0, Lokhttp3/internal/http2/Http2Reader;->logger:Ljava/util/logging/Logger;
  29. return-void
  30. .end method
  31. .method constructor <init>(Lokio/BufferedSource;Z)V
  32. .locals 1
  33. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  34. iput-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  35. iput-boolean p2, p0, Lokhttp3/internal/http2/Http2Reader;->client:Z
  36. new-instance p1, Lokhttp3/internal/http2/Http2Reader$ContinuationSource;
  37. iget-object p2, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  38. invoke-direct {p1, p2}, Lokhttp3/internal/http2/Http2Reader$ContinuationSource;-><init>(Lokio/BufferedSource;)V
  39. iput-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->continuation:Lokhttp3/internal/http2/Http2Reader$ContinuationSource;
  40. new-instance p1, Lokhttp3/internal/http2/Hpack$Reader;
  41. iget-object p2, p0, Lokhttp3/internal/http2/Http2Reader;->continuation:Lokhttp3/internal/http2/Http2Reader$ContinuationSource;
  42. const/16 v0, 0x1000
  43. invoke-direct {p1, v0, p2}, Lokhttp3/internal/http2/Hpack$Reader;-><init>(ILokio/Source;)V
  44. iput-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->hpackReader:Lokhttp3/internal/http2/Hpack$Reader;
  45. return-void
  46. .end method
  47. .method static lengthWithoutPadding(IBS)I
  48. .locals 1
  49. .annotation system Ldalvik/annotation/Throws;
  50. value = {
  51. Ljava/io/IOException;
  52. }
  53. .end annotation
  54. and-int/lit8 p1, p1, 0x8
  55. if-eqz p1, :cond_0
  56. add-int/lit8 p0, p0, -0x1
  57. :cond_0
  58. if-gt p2, p0, :cond_1
  59. sub-int/2addr p0, p2
  60. int-to-short p0, p0
  61. return p0
  62. :cond_1
  63. const/4 p1, 0x2
  64. new-array p1, p1, [Ljava/lang/Object;
  65. const/4 v0, 0x0
  66. invoke-static {p2}, Ljava/lang/Short;->valueOf(S)Ljava/lang/Short;
  67. move-result-object p2
  68. aput-object p2, p1, v0
  69. const/4 p2, 0x1
  70. invoke-static {p0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  71. move-result-object p0
  72. aput-object p0, p1, p2
  73. const-string p0, "PROTOCOL_ERROR padding %s > remaining length %s"
  74. invoke-static {p0, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  75. move-result-object p0
  76. throw p0
  77. .end method
  78. .method private readData(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  79. .locals 4
  80. .annotation system Ldalvik/annotation/Throws;
  81. value = {
  82. Ljava/io/IOException;
  83. }
  84. .end annotation
  85. const/4 v0, 0x0
  86. if-eqz p4, :cond_4
  87. and-int/lit8 v1, p3, 0x1
  88. const/4 v2, 0x1
  89. if-eqz v1, :cond_0
  90. const/4 v1, 0x1
  91. goto :goto_0
  92. :cond_0
  93. const/4 v1, 0x0
  94. :goto_0
  95. and-int/lit8 v3, p3, 0x20
  96. if-eqz v3, :cond_1
  97. goto :goto_1
  98. :cond_1
  99. const/4 v2, 0x0
  100. :goto_1
  101. if-nez v2, :cond_3
  102. and-int/lit8 v2, p3, 0x8
  103. if-eqz v2, :cond_2
  104. iget-object v0, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  105. invoke-interface {v0}, Lokio/BufferedSource;->readByte()B
  106. move-result v0
  107. and-int/lit16 v0, v0, 0xff
  108. int-to-short v0, v0
  109. :cond_2
  110. invoke-static {p2, p3, v0}, Lokhttp3/internal/http2/Http2Reader;->lengthWithoutPadding(IBS)I
  111. move-result p2
  112. iget-object p3, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  113. invoke-interface {p1, v1, p4, p3, p2}, Lokhttp3/internal/http2/Http2Reader$Handler;->data(ZILokio/BufferedSource;I)V
  114. iget-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  115. int-to-long p2, v0
  116. invoke-interface {p1, p2, p3}, Lokio/BufferedSource;->skip(J)V
  117. return-void
  118. :cond_3
  119. new-array p1, v0, [Ljava/lang/Object;
  120. const-string p2, "PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA"
  121. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  122. move-result-object p1
  123. throw p1
  124. :cond_4
  125. new-array p1, v0, [Ljava/lang/Object;
  126. const-string p2, "PROTOCOL_ERROR: TYPE_DATA streamId == 0"
  127. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  128. move-result-object p1
  129. throw p1
  130. .end method
  131. .method private readGoAway(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  132. .locals 3
  133. .annotation system Ldalvik/annotation/Throws;
  134. value = {
  135. Ljava/io/IOException;
  136. }
  137. .end annotation
  138. const/4 p3, 0x1
  139. const/16 v0, 0x8
  140. const/4 v1, 0x0
  141. if-lt p2, v0, :cond_3
  142. if-nez p4, :cond_2
  143. iget-object p4, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  144. invoke-interface {p4}, Lokio/BufferedSource;->readInt()I
  145. move-result p4
  146. iget-object v2, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  147. invoke-interface {v2}, Lokio/BufferedSource;->readInt()I
  148. move-result v2
  149. sub-int/2addr p2, v0
  150. invoke-static {v2}, Lokhttp3/internal/http2/ErrorCode;->fromHttp2(I)Lokhttp3/internal/http2/ErrorCode;
  151. move-result-object v0
  152. if-eqz v0, :cond_1
  153. sget-object p3, Lokio/ByteString;->EMPTY:Lokio/ByteString;
  154. if-lez p2, :cond_0
  155. iget-object p3, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  156. int-to-long v1, p2
  157. invoke-interface {p3, v1, v2}, Lokio/BufferedSource;->readByteString(J)Lokio/ByteString;
  158. move-result-object p3
  159. :cond_0
  160. invoke-interface {p1, p4, v0, p3}, Lokhttp3/internal/http2/Http2Reader$Handler;->goAway(ILokhttp3/internal/http2/ErrorCode;Lokio/ByteString;)V
  161. return-void
  162. :cond_1
  163. new-array p1, p3, [Ljava/lang/Object;
  164. invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  165. move-result-object p2
  166. aput-object p2, p1, v1
  167. const-string p2, "TYPE_GOAWAY unexpected error code: %d"
  168. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  169. move-result-object p1
  170. throw p1
  171. :cond_2
  172. new-array p1, v1, [Ljava/lang/Object;
  173. const-string p2, "TYPE_GOAWAY streamId != 0"
  174. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  175. move-result-object p1
  176. throw p1
  177. :cond_3
  178. new-array p1, p3, [Ljava/lang/Object;
  179. invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  180. move-result-object p2
  181. aput-object p2, p1, v1
  182. const-string p2, "TYPE_GOAWAY length < 8: %s"
  183. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  184. move-result-object p1
  185. throw p1
  186. .end method
  187. .method private readHeaderBlock(ISBI)Ljava/util/List;
  188. .locals 1
  189. .annotation system Ldalvik/annotation/Signature;
  190. value = {
  191. "(ISBI)",
  192. "Ljava/util/List<",
  193. "Lokhttp3/internal/http2/Header;",
  194. ">;"
  195. }
  196. .end annotation
  197. .annotation system Ldalvik/annotation/Throws;
  198. value = {
  199. Ljava/io/IOException;
  200. }
  201. .end annotation
  202. iget-object v0, p0, Lokhttp3/internal/http2/Http2Reader;->continuation:Lokhttp3/internal/http2/Http2Reader$ContinuationSource;
  203. iput p1, v0, Lokhttp3/internal/http2/Http2Reader$ContinuationSource;->left:I
  204. iput p1, v0, Lokhttp3/internal/http2/Http2Reader$ContinuationSource;->length:I
  205. iput-short p2, v0, Lokhttp3/internal/http2/Http2Reader$ContinuationSource;->padding:S
  206. iput-byte p3, v0, Lokhttp3/internal/http2/Http2Reader$ContinuationSource;->flags:B
  207. iput p4, v0, Lokhttp3/internal/http2/Http2Reader$ContinuationSource;->streamId:I
  208. iget-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->hpackReader:Lokhttp3/internal/http2/Hpack$Reader;
  209. invoke-virtual {p1}, Lokhttp3/internal/http2/Hpack$Reader;->readHeaders()V
  210. iget-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->hpackReader:Lokhttp3/internal/http2/Hpack$Reader;
  211. invoke-virtual {p1}, Lokhttp3/internal/http2/Hpack$Reader;->getAndResetHeaderList()Ljava/util/List;
  212. move-result-object p1
  213. return-object p1
  214. .end method
  215. .method private readHeaders(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  216. .locals 3
  217. .annotation system Ldalvik/annotation/Throws;
  218. value = {
  219. Ljava/io/IOException;
  220. }
  221. .end annotation
  222. const/4 v0, 0x0
  223. if-eqz p4, :cond_3
  224. and-int/lit8 v1, p3, 0x1
  225. if-eqz v1, :cond_0
  226. const/4 v1, 0x1
  227. goto :goto_0
  228. :cond_0
  229. const/4 v1, 0x0
  230. :goto_0
  231. and-int/lit8 v2, p3, 0x8
  232. if-eqz v2, :cond_1
  233. iget-object v0, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  234. invoke-interface {v0}, Lokio/BufferedSource;->readByte()B
  235. move-result v0
  236. and-int/lit16 v0, v0, 0xff
  237. int-to-short v0, v0
  238. :cond_1
  239. and-int/lit8 v2, p3, 0x20
  240. if-eqz v2, :cond_2
  241. invoke-direct {p0, p1, p4}, Lokhttp3/internal/http2/Http2Reader;->readPriority(Lokhttp3/internal/http2/Http2Reader$Handler;I)V
  242. add-int/lit8 p2, p2, -0x5
  243. :cond_2
  244. invoke-static {p2, p3, v0}, Lokhttp3/internal/http2/Http2Reader;->lengthWithoutPadding(IBS)I
  245. move-result p2
  246. invoke-direct {p0, p2, v0, p3, p4}, Lokhttp3/internal/http2/Http2Reader;->readHeaderBlock(ISBI)Ljava/util/List;
  247. move-result-object p2
  248. const/4 p3, -0x1
  249. invoke-interface {p1, v1, p4, p3, p2}, Lokhttp3/internal/http2/Http2Reader$Handler;->headers(ZIILjava/util/List;)V
  250. return-void
  251. :cond_3
  252. new-array p1, v0, [Ljava/lang/Object;
  253. const-string p2, "PROTOCOL_ERROR: TYPE_HEADERS streamId == 0"
  254. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  255. move-result-object p1
  256. throw p1
  257. .end method
  258. .method static readMedium(Lokio/BufferedSource;)I
  259. .locals 2
  260. .annotation system Ldalvik/annotation/Throws;
  261. value = {
  262. Ljava/io/IOException;
  263. }
  264. .end annotation
  265. invoke-interface {p0}, Lokio/BufferedSource;->readByte()B
  266. move-result v0
  267. and-int/lit16 v0, v0, 0xff
  268. shl-int/lit8 v0, v0, 0x10
  269. invoke-interface {p0}, Lokio/BufferedSource;->readByte()B
  270. move-result v1
  271. and-int/lit16 v1, v1, 0xff
  272. shl-int/lit8 v1, v1, 0x8
  273. or-int/2addr v0, v1
  274. invoke-interface {p0}, Lokio/BufferedSource;->readByte()B
  275. move-result p0
  276. and-int/lit16 p0, p0, 0xff
  277. or-int/2addr p0, v0
  278. return p0
  279. .end method
  280. .method private readPing(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  281. .locals 3
  282. .annotation system Ldalvik/annotation/Throws;
  283. value = {
  284. Ljava/io/IOException;
  285. }
  286. .end annotation
  287. const/4 v0, 0x0
  288. const/4 v1, 0x1
  289. const/16 v2, 0x8
  290. if-ne p2, v2, :cond_2
  291. if-nez p4, :cond_1
  292. iget-object p2, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  293. invoke-interface {p2}, Lokio/BufferedSource;->readInt()I
  294. move-result p2
  295. iget-object p4, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  296. invoke-interface {p4}, Lokio/BufferedSource;->readInt()I
  297. move-result p4
  298. and-int/2addr p3, v1
  299. if-eqz p3, :cond_0
  300. const/4 v0, 0x1
  301. :cond_0
  302. invoke-interface {p1, v0, p2, p4}, Lokhttp3/internal/http2/Http2Reader$Handler;->ping(ZII)V
  303. return-void
  304. :cond_1
  305. new-array p1, v0, [Ljava/lang/Object;
  306. const-string p2, "TYPE_PING streamId != 0"
  307. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  308. move-result-object p1
  309. throw p1
  310. :cond_2
  311. new-array p1, v1, [Ljava/lang/Object;
  312. invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  313. move-result-object p2
  314. aput-object p2, p1, v0
  315. const-string p2, "TYPE_PING length != 8: %s"
  316. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  317. move-result-object p1
  318. throw p1
  319. .end method
  320. .method private readPriority(Lokhttp3/internal/http2/Http2Reader$Handler;I)V
  321. .locals 4
  322. .annotation system Ldalvik/annotation/Throws;
  323. value = {
  324. Ljava/io/IOException;
  325. }
  326. .end annotation
  327. iget-object v0, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  328. invoke-interface {v0}, Lokio/BufferedSource;->readInt()I
  329. move-result v0
  330. const/high16 v1, -0x80000000
  331. and-int/2addr v1, v0
  332. const/4 v2, 0x1
  333. if-eqz v1, :cond_0
  334. const/4 v1, 0x1
  335. goto :goto_0
  336. :cond_0
  337. const/4 v1, 0x0
  338. :goto_0
  339. const v3, 0x7fffffff
  340. and-int/2addr v0, v3
  341. iget-object v3, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  342. invoke-interface {v3}, Lokio/BufferedSource;->readByte()B
  343. move-result v3
  344. and-int/lit16 v3, v3, 0xff
  345. add-int/2addr v3, v2
  346. invoke-interface {p1, p2, v0, v3, v1}, Lokhttp3/internal/http2/Http2Reader$Handler;->priority(IIIZ)V
  347. return-void
  348. .end method
  349. .method private readPriority(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  350. .locals 1
  351. .annotation system Ldalvik/annotation/Throws;
  352. value = {
  353. Ljava/io/IOException;
  354. }
  355. .end annotation
  356. const/4 p3, 0x0
  357. const/4 v0, 0x5
  358. if-ne p2, v0, :cond_1
  359. if-eqz p4, :cond_0
  360. invoke-direct {p0, p1, p4}, Lokhttp3/internal/http2/Http2Reader;->readPriority(Lokhttp3/internal/http2/Http2Reader$Handler;I)V
  361. return-void
  362. :cond_0
  363. new-array p1, p3, [Ljava/lang/Object;
  364. const-string p2, "TYPE_PRIORITY streamId == 0"
  365. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  366. move-result-object p1
  367. throw p1
  368. :cond_1
  369. const/4 p1, 0x1
  370. new-array p1, p1, [Ljava/lang/Object;
  371. invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  372. move-result-object p2
  373. aput-object p2, p1, p3
  374. const-string p2, "TYPE_PRIORITY length: %d != 5"
  375. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  376. move-result-object p1
  377. throw p1
  378. .end method
  379. .method private readPushPromise(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  380. .locals 3
  381. .annotation system Ldalvik/annotation/Throws;
  382. value = {
  383. Ljava/io/IOException;
  384. }
  385. .end annotation
  386. const/4 v0, 0x0
  387. if-eqz p4, :cond_1
  388. and-int/lit8 v1, p3, 0x8
  389. if-eqz v1, :cond_0
  390. iget-object v0, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  391. invoke-interface {v0}, Lokio/BufferedSource;->readByte()B
  392. move-result v0
  393. and-int/lit16 v0, v0, 0xff
  394. int-to-short v0, v0
  395. :cond_0
  396. iget-object v1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  397. invoke-interface {v1}, Lokio/BufferedSource;->readInt()I
  398. move-result v1
  399. const v2, 0x7fffffff
  400. and-int/2addr v1, v2
  401. add-int/lit8 p2, p2, -0x4
  402. invoke-static {p2, p3, v0}, Lokhttp3/internal/http2/Http2Reader;->lengthWithoutPadding(IBS)I
  403. move-result p2
  404. invoke-direct {p0, p2, v0, p3, p4}, Lokhttp3/internal/http2/Http2Reader;->readHeaderBlock(ISBI)Ljava/util/List;
  405. move-result-object p2
  406. invoke-interface {p1, p4, v1, p2}, Lokhttp3/internal/http2/Http2Reader$Handler;->pushPromise(IILjava/util/List;)V
  407. return-void
  408. :cond_1
  409. new-array p1, v0, [Ljava/lang/Object;
  410. const-string p2, "PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0"
  411. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  412. move-result-object p1
  413. throw p1
  414. .end method
  415. .method private readRstStream(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  416. .locals 2
  417. .annotation system Ldalvik/annotation/Throws;
  418. value = {
  419. Ljava/io/IOException;
  420. }
  421. .end annotation
  422. const/4 p3, 0x1
  423. const/4 v0, 0x0
  424. const/4 v1, 0x4
  425. if-ne p2, v1, :cond_2
  426. if-eqz p4, :cond_1
  427. iget-object p2, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  428. invoke-interface {p2}, Lokio/BufferedSource;->readInt()I
  429. move-result p2
  430. invoke-static {p2}, Lokhttp3/internal/http2/ErrorCode;->fromHttp2(I)Lokhttp3/internal/http2/ErrorCode;
  431. move-result-object v1
  432. if-eqz v1, :cond_0
  433. invoke-interface {p1, p4, v1}, Lokhttp3/internal/http2/Http2Reader$Handler;->rstStream(ILokhttp3/internal/http2/ErrorCode;)V
  434. return-void
  435. :cond_0
  436. new-array p1, p3, [Ljava/lang/Object;
  437. invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  438. move-result-object p2
  439. aput-object p2, p1, v0
  440. const-string p2, "TYPE_RST_STREAM unexpected error code: %d"
  441. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  442. move-result-object p1
  443. throw p1
  444. :cond_1
  445. new-array p1, v0, [Ljava/lang/Object;
  446. const-string p2, "TYPE_RST_STREAM streamId == 0"
  447. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  448. move-result-object p1
  449. throw p1
  450. :cond_2
  451. new-array p1, p3, [Ljava/lang/Object;
  452. invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  453. move-result-object p2
  454. aput-object p2, p1, v0
  455. const-string p2, "TYPE_RST_STREAM length: %d != 4"
  456. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  457. move-result-object p1
  458. throw p1
  459. .end method
  460. .method private readSettings(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  461. .locals 5
  462. .annotation system Ldalvik/annotation/Throws;
  463. value = {
  464. Ljava/io/IOException;
  465. }
  466. .end annotation
  467. const/4 v0, 0x0
  468. if-nez p4, :cond_8
  469. const/4 p4, 0x1
  470. and-int/2addr p3, p4
  471. if-eqz p3, :cond_1
  472. if-nez p2, :cond_0
  473. invoke-interface {p1}, Lokhttp3/internal/http2/Http2Reader$Handler;->ackSettings()V
  474. return-void
  475. :cond_0
  476. new-array p1, v0, [Ljava/lang/Object;
  477. const-string p2, "FRAME_SIZE_ERROR ack frame should be empty!"
  478. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  479. move-result-object p1
  480. throw p1
  481. :cond_1
  482. rem-int/lit8 p3, p2, 0x6
  483. if-nez p3, :cond_7
  484. new-instance p3, Lokhttp3/internal/http2/Settings;
  485. invoke-direct {p3}, Lokhttp3/internal/http2/Settings;-><init>()V
  486. const/4 v1, 0x0
  487. :goto_0
  488. if-ge v1, p2, :cond_6
  489. iget-object v2, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  490. invoke-interface {v2}, Lokio/BufferedSource;->readShort()S
  491. move-result v2
  492. iget-object v3, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  493. invoke-interface {v3}, Lokio/BufferedSource;->readInt()I
  494. move-result v3
  495. packed-switch v2, :pswitch_data_0
  496. goto :goto_1
  497. :pswitch_0
  498. const/16 v4, 0x4000
  499. if-lt v3, v4, :cond_2
  500. const v4, 0xffffff
  501. if-gt v3, v4, :cond_2
  502. goto :goto_1
  503. :cond_2
  504. new-array p1, p4, [Ljava/lang/Object;
  505. invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  506. move-result-object p2
  507. aput-object p2, p1, v0
  508. const-string p2, "PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: %s"
  509. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  510. move-result-object p1
  511. throw p1
  512. :pswitch_1
  513. const/4 v2, 0x7
  514. if-ltz v3, :cond_3
  515. goto :goto_1
  516. :cond_3
  517. new-array p1, v0, [Ljava/lang/Object;
  518. const-string p2, "PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1"
  519. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  520. move-result-object p1
  521. throw p1
  522. :pswitch_2
  523. const/4 v2, 0x4
  524. goto :goto_1
  525. :pswitch_3
  526. if-eqz v3, :cond_5
  527. if-ne v3, p4, :cond_4
  528. goto :goto_1
  529. :cond_4
  530. new-array p1, v0, [Ljava/lang/Object;
  531. const-string p2, "PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1"
  532. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  533. move-result-object p1
  534. throw p1
  535. :cond_5
  536. :goto_1
  537. :pswitch_4
  538. invoke-virtual {p3, v2, v3}, Lokhttp3/internal/http2/Settings;->set(II)Lokhttp3/internal/http2/Settings;
  539. add-int/lit8 v1, v1, 0x6
  540. goto :goto_0
  541. :cond_6
  542. invoke-interface {p1, v0, p3}, Lokhttp3/internal/http2/Http2Reader$Handler;->settings(ZLokhttp3/internal/http2/Settings;)V
  543. return-void
  544. :cond_7
  545. new-array p1, p4, [Ljava/lang/Object;
  546. invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  547. move-result-object p2
  548. aput-object p2, p1, v0
  549. const-string p2, "TYPE_SETTINGS length %% 6 != 0: %s"
  550. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  551. move-result-object p1
  552. throw p1
  553. :cond_8
  554. new-array p1, v0, [Ljava/lang/Object;
  555. const-string p2, "TYPE_SETTINGS streamId != 0"
  556. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  557. move-result-object p1
  558. goto :goto_3
  559. :goto_2
  560. throw p1
  561. :goto_3
  562. goto :goto_2
  563. :pswitch_data_0
  564. .packed-switch 0x1
  565. :pswitch_4
  566. :pswitch_3
  567. :pswitch_2
  568. :pswitch_1
  569. :pswitch_0
  570. :pswitch_4
  571. .end packed-switch
  572. .end method
  573. .method private readWindowUpdate(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  574. .locals 5
  575. .annotation system Ldalvik/annotation/Throws;
  576. value = {
  577. Ljava/io/IOException;
  578. }
  579. .end annotation
  580. const/4 p3, 0x0
  581. const/4 v0, 0x1
  582. const/4 v1, 0x4
  583. if-ne p2, v1, :cond_1
  584. iget-object p2, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  585. invoke-interface {p2}, Lokio/BufferedSource;->readInt()I
  586. move-result p2
  587. int-to-long v1, p2
  588. const-wide/32 v3, 0x7fffffff
  589. and-long/2addr v1, v3
  590. const-wide/16 v3, 0x0
  591. cmp-long p2, v1, v3
  592. if-eqz p2, :cond_0
  593. invoke-interface {p1, p4, v1, v2}, Lokhttp3/internal/http2/Http2Reader$Handler;->windowUpdate(IJ)V
  594. return-void
  595. :cond_0
  596. new-array p1, v0, [Ljava/lang/Object;
  597. invoke-static {v1, v2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
  598. move-result-object p2
  599. aput-object p2, p1, p3
  600. const-string p2, "windowSizeIncrement was 0"
  601. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  602. move-result-object p1
  603. throw p1
  604. :cond_1
  605. new-array p1, v0, [Ljava/lang/Object;
  606. invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  607. move-result-object p2
  608. aput-object p2, p1, p3
  609. const-string p2, "TYPE_WINDOW_UPDATE length !=4: %s"
  610. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  611. move-result-object p1
  612. throw p1
  613. .end method
  614. # virtual methods
  615. .method public close()V
  616. .locals 1
  617. .annotation system Ldalvik/annotation/Throws;
  618. value = {
  619. Ljava/io/IOException;
  620. }
  621. .end annotation
  622. iget-object v0, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  623. invoke-interface {v0}, Lokio/Source;->close()V
  624. return-void
  625. .end method
  626. .method public nextFrame(ZLokhttp3/internal/http2/Http2Reader$Handler;)Z
  627. .locals 6
  628. .annotation system Ldalvik/annotation/Throws;
  629. value = {
  630. Ljava/io/IOException;
  631. }
  632. .end annotation
  633. const/4 v0, 0x0
  634. :try_start_0
  635. iget-object v1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  636. const-wide/16 v2, 0x9
  637. invoke-interface {v1, v2, v3}, Lokio/BufferedSource;->require(J)V
  638. :try_end_0
  639. .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
  640. iget-object v1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  641. invoke-static {v1}, Lokhttp3/internal/http2/Http2Reader;->readMedium(Lokio/BufferedSource;)I
  642. move-result v1
  643. const/4 v2, 0x1
  644. if-ltz v1, :cond_3
  645. const/16 v3, 0x4000
  646. if-gt v1, v3, :cond_3
  647. iget-object v3, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  648. invoke-interface {v3}, Lokio/BufferedSource;->readByte()B
  649. move-result v3
  650. and-int/lit16 v3, v3, 0xff
  651. int-to-byte v3, v3
  652. if-eqz p1, :cond_1
  653. const/4 p1, 0x4
  654. if-ne v3, p1, :cond_0
  655. goto :goto_0
  656. :cond_0
  657. new-array p1, v2, [Ljava/lang/Object;
  658. invoke-static {v3}, Ljava/lang/Byte;->valueOf(B)Ljava/lang/Byte;
  659. move-result-object p2
  660. aput-object p2, p1, v0
  661. const-string p2, "Expected a SETTINGS frame but was %s"
  662. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  663. move-result-object p1
  664. throw p1
  665. :cond_1
  666. :goto_0
  667. iget-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  668. invoke-interface {p1}, Lokio/BufferedSource;->readByte()B
  669. move-result p1
  670. and-int/lit16 p1, p1, 0xff
  671. int-to-byte p1, p1
  672. iget-object v0, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  673. invoke-interface {v0}, Lokio/BufferedSource;->readInt()I
  674. move-result v0
  675. const v4, 0x7fffffff
  676. and-int/2addr v0, v4
  677. sget-object v4, Lokhttp3/internal/http2/Http2Reader;->logger:Ljava/util/logging/Logger;
  678. sget-object v5, Ljava/util/logging/Level;->FINE:Ljava/util/logging/Level;
  679. invoke-virtual {v4, v5}, Ljava/util/logging/Logger;->isLoggable(Ljava/util/logging/Level;)Z
  680. move-result v4
  681. if-eqz v4, :cond_2
  682. sget-object v4, Lokhttp3/internal/http2/Http2Reader;->logger:Ljava/util/logging/Logger;
  683. invoke-static {v2, v0, v1, v3, p1}, Lokhttp3/internal/http2/Http2;->frameLog(ZIIBB)Ljava/lang/String;
  684. move-result-object v5
  685. invoke-virtual {v4, v5}, Ljava/util/logging/Logger;->fine(Ljava/lang/String;)V
  686. :cond_2
  687. packed-switch v3, :pswitch_data_0
  688. iget-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  689. int-to-long v0, v1
  690. invoke-interface {p1, v0, v1}, Lokio/BufferedSource;->skip(J)V
  691. goto :goto_1
  692. :pswitch_0
  693. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readWindowUpdate(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  694. goto :goto_1
  695. :pswitch_1
  696. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readGoAway(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  697. goto :goto_1
  698. :pswitch_2
  699. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readPing(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  700. goto :goto_1
  701. :pswitch_3
  702. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readPushPromise(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  703. goto :goto_1
  704. :pswitch_4
  705. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readSettings(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  706. goto :goto_1
  707. :pswitch_5
  708. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readRstStream(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  709. goto :goto_1
  710. :pswitch_6
  711. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readPriority(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  712. goto :goto_1
  713. :pswitch_7
  714. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readHeaders(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  715. goto :goto_1
  716. :pswitch_8
  717. invoke-direct {p0, p2, v1, p1, v0}, Lokhttp3/internal/http2/Http2Reader;->readData(Lokhttp3/internal/http2/Http2Reader$Handler;IBI)V
  718. :goto_1
  719. return v2
  720. :cond_3
  721. new-array p1, v2, [Ljava/lang/Object;
  722. invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  723. move-result-object p2
  724. aput-object p2, p1, v0
  725. const-string p2, "FRAME_SIZE_ERROR: %s"
  726. invoke-static {p2, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  727. move-result-object p1
  728. throw p1
  729. :catch_0
  730. return v0
  731. nop
  732. :pswitch_data_0
  733. .packed-switch 0x0
  734. :pswitch_8
  735. :pswitch_7
  736. :pswitch_6
  737. :pswitch_5
  738. :pswitch_4
  739. :pswitch_3
  740. :pswitch_2
  741. :pswitch_1
  742. :pswitch_0
  743. .end packed-switch
  744. .end method
  745. .method public readConnectionPreface(Lokhttp3/internal/http2/Http2Reader$Handler;)V
  746. .locals 5
  747. .annotation system Ldalvik/annotation/Throws;
  748. value = {
  749. Ljava/io/IOException;
  750. }
  751. .end annotation
  752. iget-boolean v0, p0, Lokhttp3/internal/http2/Http2Reader;->client:Z
  753. const/4 v1, 0x0
  754. const/4 v2, 0x1
  755. if-eqz v0, :cond_1
  756. invoke-virtual {p0, v2, p1}, Lokhttp3/internal/http2/Http2Reader;->nextFrame(ZLokhttp3/internal/http2/Http2Reader$Handler;)Z
  757. move-result p1
  758. if-eqz p1, :cond_0
  759. goto :goto_0
  760. :cond_0
  761. new-array p1, v1, [Ljava/lang/Object;
  762. const-string v0, "Required SETTINGS preface not received"
  763. invoke-static {v0, p1}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  764. move-result-object p1
  765. throw p1
  766. :cond_1
  767. iget-object p1, p0, Lokhttp3/internal/http2/Http2Reader;->source:Lokio/BufferedSource;
  768. sget-object v0, Lokhttp3/internal/http2/Http2;->CONNECTION_PREFACE:Lokio/ByteString;
  769. invoke-virtual {v0}, Lokio/ByteString;->size()I
  770. move-result v0
  771. int-to-long v3, v0
  772. invoke-interface {p1, v3, v4}, Lokio/BufferedSource;->readByteString(J)Lokio/ByteString;
  773. move-result-object p1
  774. sget-object v0, Lokhttp3/internal/http2/Http2Reader;->logger:Ljava/util/logging/Logger;
  775. sget-object v3, Ljava/util/logging/Level;->FINE:Ljava/util/logging/Level;
  776. invoke-virtual {v0, v3}, Ljava/util/logging/Logger;->isLoggable(Ljava/util/logging/Level;)Z
  777. move-result v0
  778. if-eqz v0, :cond_2
  779. sget-object v0, Lokhttp3/internal/http2/Http2Reader;->logger:Ljava/util/logging/Logger;
  780. new-array v3, v2, [Ljava/lang/Object;
  781. invoke-virtual {p1}, Lokio/ByteString;->hex()Ljava/lang/String;
  782. move-result-object v4
  783. aput-object v4, v3, v1
  784. const-string v4, "<< CONNECTION %s"
  785. invoke-static {v4, v3}, Lokhttp3/internal/Util;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
  786. move-result-object v3
  787. invoke-virtual {v0, v3}, Ljava/util/logging/Logger;->fine(Ljava/lang/String;)V
  788. :cond_2
  789. sget-object v0, Lokhttp3/internal/http2/Http2;->CONNECTION_PREFACE:Lokio/ByteString;
  790. invoke-virtual {v0, p1}, Lokio/ByteString;->equals(Ljava/lang/Object;)Z
  791. move-result v0
  792. if-eqz v0, :cond_3
  793. :goto_0
  794. return-void
  795. :cond_3
  796. new-array v0, v2, [Ljava/lang/Object;
  797. invoke-virtual {p1}, Lokio/ByteString;->utf8()Ljava/lang/String;
  798. move-result-object p1
  799. aput-object p1, v0, v1
  800. const-string p1, "Expected a connection header but was %s"
  801. invoke-static {p1, v0}, Lokhttp3/internal/http2/Http2;->ioException(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/IOException;
  802. move-result-object p1
  803. throw p1
  804. .end method