MockWebServer$Http2SocketHandler.smali 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. .class Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;
  2. .super Lokhttp3/internal/http2/Http2Connection$Listener;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/mockwebserver/MockWebServer;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x2
  10. name = "Http2SocketHandler"
  11. .end annotation
  12. # instance fields
  13. .field private final protocol:Lokhttp3/Protocol;
  14. .field private final sequenceNumber:Ljava/util/concurrent/atomic/AtomicInteger;
  15. .field private final socket:Ljava/net/Socket;
  16. .field final synthetic this$0:Lokhttp3/mockwebserver/MockWebServer;
  17. # direct methods
  18. .method private constructor <init>(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;Lokhttp3/Protocol;)V
  19. .locals 0
  20. iput-object p1, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  21. invoke-direct {p0}, Lokhttp3/internal/http2/Http2Connection$Listener;-><init>()V
  22. new-instance p1, Ljava/util/concurrent/atomic/AtomicInteger;
  23. invoke-direct {p1}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>()V
  24. iput-object p1, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->sequenceNumber:Ljava/util/concurrent/atomic/AtomicInteger;
  25. iput-object p2, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->socket:Ljava/net/Socket;
  26. iput-object p3, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->protocol:Lokhttp3/Protocol;
  27. return-void
  28. .end method
  29. .method synthetic constructor <init>(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;Lokhttp3/Protocol;Lokhttp3/mockwebserver/MockWebServer$1;)V
  30. .locals 0
  31. invoke-direct {p0, p1, p2, p3}, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;-><init>(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;Lokhttp3/Protocol;)V
  32. return-void
  33. .end method
  34. .method private pushPromises(Lokhttp3/internal/http2/Http2Stream;Ljava/util/List;)V
  35. .locals 16
  36. .annotation system Ldalvik/annotation/Signature;
  37. value = {
  38. "(",
  39. "Lokhttp3/internal/http2/Http2Stream;",
  40. "Ljava/util/List<",
  41. "Lokhttp3/mockwebserver/PushPromise;",
  42. ">;)V"
  43. }
  44. .end annotation
  45. .annotation system Ldalvik/annotation/Throws;
  46. value = {
  47. Ljava/io/IOException;
  48. }
  49. .end annotation
  50. move-object/from16 v0, p0
  51. invoke-interface/range {p2 .. p2}, Ljava/util/List;->iterator()Ljava/util/Iterator;
  52. move-result-object v1
  53. :goto_0
  54. invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
  55. move-result v2
  56. if-eqz v2, :cond_2
  57. invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  58. move-result-object v2
  59. check-cast v2, Lokhttp3/mockwebserver/PushPromise;
  60. new-instance v3, Ljava/util/ArrayList;
  61. invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V
  62. new-instance v4, Lokhttp3/internal/http2/Header;
  63. sget-object v5, Lokhttp3/internal/http2/Header;->TARGET_AUTHORITY:Lokio/ByteString;
  64. iget-object v6, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  65. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->path()Ljava/lang/String;
  66. move-result-object v7
  67. invoke-virtual {v6, v7}, Lokhttp3/mockwebserver/MockWebServer;->url(Ljava/lang/String;)Lokhttp3/HttpUrl;
  68. move-result-object v6
  69. invoke-virtual {v6}, Lokhttp3/HttpUrl;->host()Ljava/lang/String;
  70. move-result-object v6
  71. invoke-direct {v4, v5, v6}, Lokhttp3/internal/http2/Header;-><init>(Lokio/ByteString;Ljava/lang/String;)V
  72. invoke-interface {v3, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  73. new-instance v4, Lokhttp3/internal/http2/Header;
  74. sget-object v5, Lokhttp3/internal/http2/Header;->TARGET_METHOD:Lokio/ByteString;
  75. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->method()Ljava/lang/String;
  76. move-result-object v6
  77. invoke-direct {v4, v5, v6}, Lokhttp3/internal/http2/Header;-><init>(Lokio/ByteString;Ljava/lang/String;)V
  78. invoke-interface {v3, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  79. new-instance v4, Lokhttp3/internal/http2/Header;
  80. sget-object v5, Lokhttp3/internal/http2/Header;->TARGET_PATH:Lokio/ByteString;
  81. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->path()Ljava/lang/String;
  82. move-result-object v6
  83. invoke-direct {v4, v5, v6}, Lokhttp3/internal/http2/Header;-><init>(Lokio/ByteString;Ljava/lang/String;)V
  84. invoke-interface {v3, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  85. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->headers()Lokhttp3/Headers;
  86. move-result-object v4
  87. invoke-virtual {v4}, Lokhttp3/Headers;->size()I
  88. move-result v5
  89. const/4 v6, 0x0
  90. const/4 v7, 0x0
  91. :goto_1
  92. if-ge v7, v5, :cond_0
  93. new-instance v8, Lokhttp3/internal/http2/Header;
  94. invoke-virtual {v4, v7}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
  95. move-result-object v9
  96. invoke-virtual {v4, v7}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
  97. move-result-object v10
  98. invoke-direct {v8, v9, v10}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
  99. invoke-interface {v3, v8}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  100. add-int/lit8 v7, v7, 0x1
  101. goto :goto_1
  102. :cond_0
  103. new-instance v4, Ljava/lang/StringBuilder;
  104. invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
  105. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->method()Ljava/lang/String;
  106. move-result-object v5
  107. invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  108. const/16 v5, 0x20
  109. invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
  110. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->path()Ljava/lang/String;
  111. move-result-object v5
  112. invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  113. const-string v5, " HTTP/1.1"
  114. invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  115. invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  116. move-result-object v8
  117. invoke-static {}, Ljava/util/Collections;->emptyList()Ljava/util/List;
  118. move-result-object v10
  119. iget-object v4, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  120. invoke-static {v4}, Lokhttp3/mockwebserver/MockWebServer;->access$1600(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/concurrent/BlockingQueue;
  121. move-result-object v4
  122. new-instance v5, Lokhttp3/mockwebserver/RecordedRequest;
  123. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->headers()Lokhttp3/Headers;
  124. move-result-object v9
  125. const-wide/16 v11, 0x0
  126. new-instance v13, Lokio/Buffer;
  127. invoke-direct {v13}, Lokio/Buffer;-><init>()V
  128. iget-object v7, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->sequenceNumber:Ljava/util/concurrent/atomic/AtomicInteger;
  129. invoke-virtual {v7}, Ljava/util/concurrent/atomic/AtomicInteger;->getAndIncrement()I
  130. move-result v14
  131. iget-object v15, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->socket:Ljava/net/Socket;
  132. move-object v7, v5
  133. invoke-direct/range {v7 .. v15}, Lokhttp3/mockwebserver/RecordedRequest;-><init>(Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILjava/net/Socket;)V
  134. invoke-interface {v4, v5}, Ljava/util/concurrent/BlockingQueue;->add(Ljava/lang/Object;)Z
  135. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->response()Lokhttp3/mockwebserver/MockResponse;
  136. move-result-object v4
  137. invoke-virtual {v4}, Lokhttp3/mockwebserver/MockResponse;->getBody()Lokio/Buffer;
  138. move-result-object v4
  139. if-eqz v4, :cond_1
  140. const/4 v6, 0x1
  141. :cond_1
  142. invoke-virtual/range {p1 .. p1}, Lokhttp3/internal/http2/Http2Stream;->getConnection()Lokhttp3/internal/http2/Http2Connection;
  143. move-result-object v4
  144. invoke-virtual/range {p1 .. p1}, Lokhttp3/internal/http2/Http2Stream;->getId()I
  145. move-result v5
  146. invoke-virtual {v4, v5, v3, v6}, Lokhttp3/internal/http2/Http2Connection;->pushStream(ILjava/util/List;Z)Lokhttp3/internal/http2/Http2Stream;
  147. move-result-object v3
  148. invoke-virtual {v2}, Lokhttp3/mockwebserver/PushPromise;->response()Lokhttp3/mockwebserver/MockResponse;
  149. move-result-object v2
  150. invoke-direct {v0, v3, v2}, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->writeResponse(Lokhttp3/internal/http2/Http2Stream;Lokhttp3/mockwebserver/MockResponse;)V
  151. goto/16 :goto_0
  152. :cond_2
  153. return-void
  154. .end method
  155. .method private readRequest(Lokhttp3/internal/http2/Http2Stream;)Lokhttp3/mockwebserver/RecordedRequest;
  156. .locals 18
  157. .annotation system Ldalvik/annotation/Throws;
  158. value = {
  159. Ljava/io/IOException;
  160. }
  161. .end annotation
  162. move-object/from16 v0, p0
  163. invoke-virtual/range {p1 .. p1}, Lokhttp3/internal/http2/Http2Stream;->getRequestHeaders()Ljava/util/List;
  164. move-result-object v1
  165. new-instance v2, Lokhttp3/Headers$Builder;
  166. invoke-direct {v2}, Lokhttp3/Headers$Builder;-><init>()V
  167. invoke-interface {v1}, Ljava/util/List;->size()I
  168. move-result v3
  169. const/4 v4, 0x0
  170. const/4 v5, 0x1
  171. const-string v6, "<:method omitted>"
  172. const-string v7, "<:path omitted>"
  173. move-object v8, v6
  174. move-object v9, v7
  175. const/4 v6, 0x0
  176. const/4 v7, 0x1
  177. :goto_0
  178. if-ge v6, v3, :cond_4
  179. invoke-interface {v1, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;
  180. move-result-object v10
  181. check-cast v10, Lokhttp3/internal/http2/Header;
  182. iget-object v10, v10, Lokhttp3/internal/http2/Header;->name:Lokio/ByteString;
  183. invoke-interface {v1, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;
  184. move-result-object v11
  185. check-cast v11, Lokhttp3/internal/http2/Header;
  186. iget-object v11, v11, Lokhttp3/internal/http2/Header;->value:Lokio/ByteString;
  187. invoke-virtual {v11}, Lokio/ByteString;->utf8()Ljava/lang/String;
  188. move-result-object v11
  189. sget-object v12, Lokhttp3/internal/http2/Header;->TARGET_METHOD:Lokio/ByteString;
  190. invoke-virtual {v10, v12}, Lokio/ByteString;->equals(Ljava/lang/Object;)Z
  191. move-result v12
  192. if-eqz v12, :cond_0
  193. move-object v8, v11
  194. goto :goto_1
  195. :cond_0
  196. sget-object v12, Lokhttp3/internal/http2/Header;->TARGET_PATH:Lokio/ByteString;
  197. invoke-virtual {v10, v12}, Lokio/ByteString;->equals(Ljava/lang/Object;)Z
  198. move-result v12
  199. if-eqz v12, :cond_1
  200. move-object v9, v11
  201. goto :goto_1
  202. :cond_1
  203. iget-object v12, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->protocol:Lokhttp3/Protocol;
  204. sget-object v13, Lokhttp3/Protocol;->HTTP_2:Lokhttp3/Protocol;
  205. if-ne v12, v13, :cond_3
  206. invoke-virtual {v10}, Lokio/ByteString;->utf8()Ljava/lang/String;
  207. move-result-object v12
  208. invoke-virtual {v2, v12, v11}, Lokhttp3/Headers$Builder;->add(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  209. :goto_1
  210. invoke-virtual {v10}, Lokio/ByteString;->utf8()Ljava/lang/String;
  211. move-result-object v10
  212. const-string v12, "expect"
  213. invoke-virtual {v10, v12}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  214. move-result v10
  215. if-eqz v10, :cond_2
  216. const-string v10, "100-continue"
  217. invoke-virtual {v11, v10}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  218. move-result v10
  219. if-eqz v10, :cond_2
  220. const/4 v7, 0x0
  221. :cond_2
  222. add-int/lit8 v6, v6, 0x1
  223. goto :goto_0
  224. :cond_3
  225. new-instance v1, Ljava/lang/IllegalStateException;
  226. invoke-direct {v1}, Ljava/lang/IllegalStateException;-><init>()V
  227. throw v1
  228. :cond_4
  229. invoke-virtual {v2}, Lokhttp3/Headers$Builder;->build()Lokhttp3/Headers;
  230. move-result-object v4
  231. iget-object v1, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  232. invoke-static {v1}, Lokhttp3/mockwebserver/MockWebServer;->access$400(Lokhttp3/mockwebserver/MockWebServer;)Lokhttp3/mockwebserver/Dispatcher;
  233. move-result-object v1
  234. invoke-virtual {v1}, Lokhttp3/mockwebserver/Dispatcher;->peek()Lokhttp3/mockwebserver/MockResponse;
  235. move-result-object v11
  236. if-nez v7, :cond_5
  237. invoke-virtual {v11}, Lokhttp3/mockwebserver/MockResponse;->getSocketPolicy()Lokhttp3/mockwebserver/SocketPolicy;
  238. move-result-object v1
  239. sget-object v2, Lokhttp3/mockwebserver/SocketPolicy;->EXPECT_CONTINUE:Lokhttp3/mockwebserver/SocketPolicy;
  240. if-ne v1, v2, :cond_5
  241. new-instance v1, Lokhttp3/internal/http2/Header;
  242. sget-object v2, Lokhttp3/internal/http2/Header;->RESPONSE_STATUS:Lokio/ByteString;
  243. const-string v3, "100 Continue"
  244. invoke-static {v3}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
  245. move-result-object v3
  246. invoke-direct {v1, v2, v3}, Lokhttp3/internal/http2/Header;-><init>(Lokio/ByteString;Lokio/ByteString;)V
  247. invoke-static {v1}, Ljava/util/Collections;->singletonList(Ljava/lang/Object;)Ljava/util/List;
  248. move-result-object v1
  249. move-object/from16 v2, p1
  250. invoke-virtual {v2, v1, v5}, Lokhttp3/internal/http2/Http2Stream;->sendResponseHeaders(Ljava/util/List;Z)V
  251. invoke-virtual/range {p1 .. p1}, Lokhttp3/internal/http2/Http2Stream;->getConnection()Lokhttp3/internal/http2/Http2Connection;
  252. move-result-object v1
  253. invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Connection;->flush()V
  254. goto :goto_2
  255. :cond_5
  256. move-object/from16 v2, p1
  257. move v5, v7
  258. :goto_2
  259. new-instance v1, Lokio/Buffer;
  260. invoke-direct {v1}, Lokio/Buffer;-><init>()V
  261. if-eqz v5, :cond_7
  262. const-string v3, "content-length"
  263. invoke-virtual {v4, v3}, Lokhttp3/Headers;->get(Ljava/lang/String;)Ljava/lang/String;
  264. move-result-object v3
  265. if-eqz v3, :cond_6
  266. invoke-static {v3}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J
  267. move-result-wide v5
  268. goto :goto_3
  269. :cond_6
  270. const-wide v5, 0x7fffffffffffffffL
  271. :goto_3
  272. move-wide v15, v5
  273. iget-object v10, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  274. iget-object v12, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->socket:Ljava/net/Socket;
  275. invoke-virtual/range {p1 .. p1}, Lokhttp3/internal/http2/Http2Stream;->getSource()Lokio/Source;
  276. move-result-object v2
  277. invoke-static {v2}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
  278. move-result-object v13
  279. const/16 v17, 0x1
  280. move-object v14, v1
  281. invoke-static/range {v10 .. v17}, Lokhttp3/mockwebserver/MockWebServer;->access$2100(Lokhttp3/mockwebserver/MockWebServer;Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  282. :cond_7
  283. new-instance v2, Ljava/lang/StringBuilder;
  284. invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
  285. invoke-virtual {v2, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  286. const/16 v3, 0x20
  287. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
  288. invoke-virtual {v2, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  289. const-string v3, " HTTP/1.1"
  290. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  291. invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  292. move-result-object v3
  293. invoke-static {}, Ljava/util/Collections;->emptyList()Ljava/util/List;
  294. move-result-object v5
  295. new-instance v11, Lokhttp3/mockwebserver/RecordedRequest;
  296. invoke-virtual {v1}, Lokio/Buffer;->size()J
  297. move-result-wide v6
  298. iget-object v2, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->sequenceNumber:Ljava/util/concurrent/atomic/AtomicInteger;
  299. invoke-virtual {v2}, Ljava/util/concurrent/atomic/AtomicInteger;->getAndIncrement()I
  300. move-result v9
  301. iget-object v10, v0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->socket:Ljava/net/Socket;
  302. move-object v2, v11
  303. move-object v8, v1
  304. invoke-direct/range {v2 .. v10}, Lokhttp3/mockwebserver/RecordedRequest;-><init>(Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILjava/net/Socket;)V
  305. return-object v11
  306. .end method
  307. .method private writeResponse(Lokhttp3/internal/http2/Http2Stream;Lokhttp3/mockwebserver/MockResponse;)V
  308. .locals 11
  309. .annotation system Ldalvik/annotation/Throws;
  310. value = {
  311. Ljava/io/IOException;
  312. }
  313. .end annotation
  314. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getSettings()Lokhttp3/internal/http2/Settings;
  315. move-result-object v2
  316. if-eqz v2, :cond_0
  317. invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream;->getConnection()Lokhttp3/internal/http2/Http2Connection;
  318. move-result-object v3
  319. invoke-virtual {v3, v2}, Lokhttp3/internal/http2/Http2Connection;->setSettings(Lokhttp3/internal/http2/Settings;)V
  320. :cond_0
  321. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getSocketPolicy()Lokhttp3/mockwebserver/SocketPolicy;
  322. move-result-object v2
  323. sget-object v3, Lokhttp3/mockwebserver/SocketPolicy;->NO_RESPONSE:Lokhttp3/mockwebserver/SocketPolicy;
  324. if-ne v2, v3, :cond_1
  325. return-void
  326. :cond_1
  327. new-instance v2, Ljava/util/ArrayList;
  328. invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V
  329. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getStatus()Ljava/lang/String;
  330. move-result-object v3
  331. const/4 v4, 0x3
  332. const-string v5, " "
  333. invoke-virtual {v3, v5, v4}, Ljava/lang/String;->split(Ljava/lang/String;I)[Ljava/lang/String;
  334. move-result-object v3
  335. array-length v4, v3
  336. const/4 v5, 0x2
  337. if-lt v4, v5, :cond_7
  338. new-instance v4, Lokhttp3/internal/http2/Header;
  339. sget-object v5, Lokhttp3/internal/http2/Header;->RESPONSE_STATUS:Lokio/ByteString;
  340. const/4 v6, 0x1
  341. aget-object v3, v3, v6
  342. invoke-direct {v4, v5, v3}, Lokhttp3/internal/http2/Header;-><init>(Lokio/ByteString;Ljava/lang/String;)V
  343. invoke-interface {v2, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  344. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getHeaders()Lokhttp3/Headers;
  345. move-result-object v3
  346. invoke-virtual {v3}, Lokhttp3/Headers;->size()I
  347. move-result v4
  348. const/4 v5, 0x0
  349. const/4 v7, 0x0
  350. :goto_0
  351. if-ge v7, v4, :cond_2
  352. new-instance v8, Lokhttp3/internal/http2/Header;
  353. invoke-virtual {v3, v7}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
  354. move-result-object v9
  355. invoke-virtual {v3, v7}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
  356. move-result-object v10
  357. invoke-direct {v8, v9, v10}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
  358. invoke-interface {v2, v8}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  359. add-int/lit8 v7, v7, 0x1
  360. goto :goto_0
  361. :cond_2
  362. iget-object v3, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  363. sget-object v4, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
  364. invoke-virtual {p2, v4}, Lokhttp3/mockwebserver/MockResponse;->getHeadersDelay(Ljava/util/concurrent/TimeUnit;)J
  365. move-result-wide v7
  366. invoke-static {v3, v7, v8}, Lokhttp3/mockwebserver/MockWebServer;->access$2200(Lokhttp3/mockwebserver/MockWebServer;J)V
  367. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getBody()Lokio/Buffer;
  368. move-result-object v3
  369. if-nez v3, :cond_3
  370. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getPushPromises()Ljava/util/List;
  371. move-result-object v4
  372. invoke-interface {v4}, Ljava/util/List;->isEmpty()Z
  373. move-result v4
  374. if-nez v4, :cond_4
  375. :cond_3
  376. const/4 v5, 0x1
  377. :cond_4
  378. invoke-virtual {p1, v2, v5}, Lokhttp3/internal/http2/Http2Stream;->sendResponseHeaders(Ljava/util/List;Z)V
  379. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getPushPromises()Ljava/util/List;
  380. move-result-object v2
  381. invoke-direct {p0, p1, v2}, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->pushPromises(Lokhttp3/internal/http2/Http2Stream;Ljava/util/List;)V
  382. if-eqz v3, :cond_5
  383. invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream;->getSink()Lokio/Sink;
  384. move-result-object v0
  385. invoke-static {v0}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
  386. move-result-object v8
  387. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  388. sget-object v2, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
  389. invoke-virtual {p2, v2}, Lokhttp3/mockwebserver/MockResponse;->getBodyDelay(Ljava/util/concurrent/TimeUnit;)J
  390. move-result-wide v4
  391. invoke-static {v0, v4, v5}, Lokhttp3/mockwebserver/MockWebServer;->access$2200(Lokhttp3/mockwebserver/MockWebServer;J)V
  392. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  393. iget-object v2, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->socket:Ljava/net/Socket;
  394. invoke-virtual {v3}, Lokio/Buffer;->size()J
  395. move-result-wide v5
  396. const/4 v7, 0x0
  397. move-object v1, p2
  398. move-object v4, v8
  399. invoke-static/range {v0 .. v7}, Lokhttp3/mockwebserver/MockWebServer;->access$2100(Lokhttp3/mockwebserver/MockWebServer;Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  400. invoke-interface {v8}, Lokio/Sink;->close()V
  401. goto :goto_1
  402. :cond_5
  403. if-eqz v5, :cond_6
  404. sget-object v1, Lokhttp3/internal/http2/ErrorCode;->NO_ERROR:Lokhttp3/internal/http2/ErrorCode;
  405. invoke-virtual {p1, v1}, Lokhttp3/internal/http2/Http2Stream;->close(Lokhttp3/internal/http2/ErrorCode;)V
  406. :cond_6
  407. :goto_1
  408. return-void
  409. :cond_7
  410. new-instance v0, Ljava/lang/AssertionError;
  411. new-instance v2, Ljava/lang/StringBuilder;
  412. invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
  413. const-string v3, "Unexpected status: "
  414. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  415. invoke-virtual {p2}, Lokhttp3/mockwebserver/MockResponse;->getStatus()Ljava/lang/String;
  416. move-result-object v1
  417. invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  418. invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  419. move-result-object v1
  420. invoke-direct {v0, v1}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  421. goto :goto_3
  422. :goto_2
  423. throw v0
  424. :goto_3
  425. goto :goto_2
  426. .end method
  427. # virtual methods
  428. .method public onStream(Lokhttp3/internal/http2/Http2Stream;)V
  429. .locals 5
  430. .annotation system Ldalvik/annotation/Throws;
  431. value = {
  432. Ljava/io/IOException;
  433. }
  434. .end annotation
  435. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  436. invoke-static {v0}, Lokhttp3/mockwebserver/MockWebServer;->access$400(Lokhttp3/mockwebserver/MockWebServer;)Lokhttp3/mockwebserver/Dispatcher;
  437. move-result-object v0
  438. invoke-virtual {v0}, Lokhttp3/mockwebserver/Dispatcher;->peek()Lokhttp3/mockwebserver/MockResponse;
  439. move-result-object v0
  440. invoke-virtual {v0}, Lokhttp3/mockwebserver/MockResponse;->getSocketPolicy()Lokhttp3/mockwebserver/SocketPolicy;
  441. move-result-object v1
  442. sget-object v2, Lokhttp3/mockwebserver/SocketPolicy;->RESET_STREAM_AT_START:Lokhttp3/mockwebserver/SocketPolicy;
  443. if-ne v1, v2, :cond_0
  444. :try_start_0
  445. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  446. iget-object v2, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->sequenceNumber:Ljava/util/concurrent/atomic/AtomicInteger;
  447. invoke-virtual {v2}, Ljava/util/concurrent/atomic/AtomicInteger;->getAndIncrement()I
  448. move-result v2
  449. iget-object v3, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->socket:Ljava/net/Socket;
  450. invoke-static {v1, v2, v3}, Lokhttp3/mockwebserver/MockWebServer;->access$600(Lokhttp3/mockwebserver/MockWebServer;ILjava/net/Socket;)V
  451. invoke-virtual {v0}, Lokhttp3/mockwebserver/MockResponse;->getHttp2ErrorCode()I
  452. move-result v0
  453. invoke-static {v0}, Lokhttp3/internal/http2/ErrorCode;->fromHttp2(I)Lokhttp3/internal/http2/ErrorCode;
  454. move-result-object v0
  455. invoke-virtual {p1, v0}, Lokhttp3/internal/http2/Http2Stream;->close(Lokhttp3/internal/http2/ErrorCode;)V
  456. :try_end_0
  457. .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0
  458. return-void
  459. :catch_0
  460. new-instance p1, Ljava/io/InterruptedIOException;
  461. invoke-direct {p1}, Ljava/io/InterruptedIOException;-><init>()V
  462. throw p1
  463. :cond_0
  464. invoke-direct {p0, p1}, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->readRequest(Lokhttp3/internal/http2/Http2Stream;)Lokhttp3/mockwebserver/RecordedRequest;
  465. move-result-object v0
  466. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  467. invoke-static {v1}, Lokhttp3/mockwebserver/MockWebServer;->access$1500(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/concurrent/atomic/AtomicInteger;
  468. move-result-object v1
  469. invoke-virtual {v1}, Ljava/util/concurrent/atomic/AtomicInteger;->incrementAndGet()I
  470. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  471. invoke-static {v1}, Lokhttp3/mockwebserver/MockWebServer;->access$1600(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/concurrent/BlockingQueue;
  472. move-result-object v1
  473. invoke-interface {v1, v0}, Ljava/util/concurrent/BlockingQueue;->add(Ljava/lang/Object;)Z
  474. :try_start_1
  475. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  476. invoke-static {v1}, Lokhttp3/mockwebserver/MockWebServer;->access$400(Lokhttp3/mockwebserver/MockWebServer;)Lokhttp3/mockwebserver/Dispatcher;
  477. move-result-object v1
  478. invoke-virtual {v1, v0}, Lokhttp3/mockwebserver/Dispatcher;->dispatch(Lokhttp3/mockwebserver/RecordedRequest;)Lokhttp3/mockwebserver/MockResponse;
  479. move-result-object v1
  480. :try_end_1
  481. .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_1
  482. invoke-virtual {v1}, Lokhttp3/mockwebserver/MockResponse;->getSocketPolicy()Lokhttp3/mockwebserver/SocketPolicy;
  483. move-result-object v2
  484. sget-object v3, Lokhttp3/mockwebserver/SocketPolicy;->DISCONNECT_AFTER_REQUEST:Lokhttp3/mockwebserver/SocketPolicy;
  485. if-ne v2, v3, :cond_1
  486. iget-object p1, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->socket:Ljava/net/Socket;
  487. invoke-virtual {p1}, Ljava/net/Socket;->close()V
  488. return-void
  489. :cond_1
  490. invoke-direct {p0, p1, v1}, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->writeResponse(Lokhttp3/internal/http2/Http2Stream;Lokhttp3/mockwebserver/MockResponse;)V
  491. invoke-static {}, Lokhttp3/mockwebserver/MockWebServer;->access$000()Ljava/util/logging/Logger;
  492. move-result-object v2
  493. sget-object v3, Ljava/util/logging/Level;->INFO:Ljava/util/logging/Level;
  494. invoke-virtual {v2, v3}, Ljava/util/logging/Logger;->isLoggable(Ljava/util/logging/Level;)Z
  495. move-result v2
  496. if-eqz v2, :cond_2
  497. invoke-static {}, Lokhttp3/mockwebserver/MockWebServer;->access$000()Ljava/util/logging/Logger;
  498. move-result-object v2
  499. new-instance v3, Ljava/lang/StringBuilder;
  500. invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
  501. iget-object v4, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->this$0:Lokhttp3/mockwebserver/MockWebServer;
  502. invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  503. const-string v4, " received request: "
  504. invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  505. invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  506. const-string v0, " and responded: "
  507. invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  508. invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  509. const-string v0, " protocol is "
  510. invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  511. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;->protocol:Lokhttp3/Protocol;
  512. invoke-virtual {v0}, Lokhttp3/Protocol;->toString()Ljava/lang/String;
  513. move-result-object v0
  514. invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  515. invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  516. move-result-object v0
  517. invoke-virtual {v2, v0}, Ljava/util/logging/Logger;->info(Ljava/lang/String;)V
  518. :cond_2
  519. invoke-virtual {v1}, Lokhttp3/mockwebserver/MockResponse;->getSocketPolicy()Lokhttp3/mockwebserver/SocketPolicy;
  520. move-result-object v0
  521. sget-object v1, Lokhttp3/mockwebserver/SocketPolicy;->DISCONNECT_AT_END:Lokhttp3/mockwebserver/SocketPolicy;
  522. if-ne v0, v1, :cond_3
  523. invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream;->getConnection()Lokhttp3/internal/http2/Http2Connection;
  524. move-result-object p1
  525. sget-object v0, Lokhttp3/internal/http2/ErrorCode;->NO_ERROR:Lokhttp3/internal/http2/ErrorCode;
  526. invoke-virtual {p1, v0}, Lokhttp3/internal/http2/Http2Connection;->shutdown(Lokhttp3/internal/http2/ErrorCode;)V
  527. :cond_3
  528. return-void
  529. :catch_1
  530. move-exception p1
  531. new-instance v0, Ljava/lang/AssertionError;
  532. invoke-direct {v0, p1}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  533. throw v0
  534. .end method