MockWebServer.smali 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226
  1. .class public final Lokhttp3/mockwebserver/MockWebServer;
  2. .super Lorg/junit/rules/ExternalResource;
  3. .source ""
  4. # interfaces
  5. .implements Ljava/io/Closeable;
  6. # annotations
  7. .annotation system Ldalvik/annotation/MemberClasses;
  8. value = {
  9. Lokhttp3/mockwebserver/MockWebServer$Http2SocketHandler;,
  10. Lokhttp3/mockwebserver/MockWebServer$TruncatingBuffer;
  11. }
  12. .end annotation
  13. # static fields
  14. .field private static final UNTRUSTED_TRUST_MANAGER:Ljavax/net/ssl/X509TrustManager;
  15. .field private static final logger:Ljava/util/logging/Logger;
  16. # instance fields
  17. .field private bodyLimit:J
  18. .field private dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  19. .field private executor:Ljava/util/concurrent/ExecutorService;
  20. .field private inetSocketAddress:Ljava/net/InetSocketAddress;
  21. .field private final openClientSockets:Ljava/util/Set;
  22. .annotation system Ldalvik/annotation/Signature;
  23. value = {
  24. "Ljava/util/Set<",
  25. "Ljava/net/Socket;",
  26. ">;"
  27. }
  28. .end annotation
  29. .end field
  30. .field private final openConnections:Ljava/util/Set;
  31. .annotation system Ldalvik/annotation/Signature;
  32. value = {
  33. "Ljava/util/Set<",
  34. "Lokhttp3/internal/http2/Http2Connection;",
  35. ">;"
  36. }
  37. .end annotation
  38. .end field
  39. .field private port:I
  40. .field private protocolNegotiationEnabled:Z
  41. .field private protocols:Ljava/util/List;
  42. .annotation system Ldalvik/annotation/Signature;
  43. value = {
  44. "Ljava/util/List<",
  45. "Lokhttp3/Protocol;",
  46. ">;"
  47. }
  48. .end annotation
  49. .end field
  50. .field private final requestCount:Ljava/util/concurrent/atomic/AtomicInteger;
  51. .field private final requestQueue:Ljava/util/concurrent/BlockingQueue;
  52. .annotation system Ldalvik/annotation/Signature;
  53. value = {
  54. "Ljava/util/concurrent/BlockingQueue<",
  55. "Lokhttp3/mockwebserver/RecordedRequest;",
  56. ">;"
  57. }
  58. .end annotation
  59. .end field
  60. .field private serverSocket:Ljava/net/ServerSocket;
  61. .field private serverSocketFactory:Ljavax/net/ServerSocketFactory;
  62. .field private sslSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
  63. .field private started:Z
  64. .field private tunnelProxy:Z
  65. # direct methods
  66. .method static constructor <clinit>()V
  67. .locals 1
  68. invoke-static {}, Lokhttp3/internal/Internal;->initializeInstanceForTests()V
  69. new-instance v0, Lokhttp3/mockwebserver/MockWebServer$1;
  70. invoke-direct {v0}, Lokhttp3/mockwebserver/MockWebServer$1;-><init>()V
  71. sput-object v0, Lokhttp3/mockwebserver/MockWebServer;->UNTRUSTED_TRUST_MANAGER:Ljavax/net/ssl/X509TrustManager;
  72. const-class v0, Lokhttp3/mockwebserver/MockWebServer;
  73. invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
  74. move-result-object v0
  75. invoke-static {v0}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
  76. move-result-object v0
  77. sput-object v0, Lokhttp3/mockwebserver/MockWebServer;->logger:Ljava/util/logging/Logger;
  78. return-void
  79. .end method
  80. .method public constructor <init>()V
  81. .locals 4
  82. invoke-direct {p0}, Lorg/junit/rules/ExternalResource;-><init>()V
  83. new-instance v0, Ljava/util/concurrent/LinkedBlockingQueue;
  84. invoke-direct {v0}, Ljava/util/concurrent/LinkedBlockingQueue;-><init>()V
  85. iput-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->requestQueue:Ljava/util/concurrent/BlockingQueue;
  86. new-instance v0, Ljava/util/concurrent/ConcurrentHashMap;
  87. invoke-direct {v0}, Ljava/util/concurrent/ConcurrentHashMap;-><init>()V
  88. invoke-static {v0}, Ljava/util/Collections;->newSetFromMap(Ljava/util/Map;)Ljava/util/Set;
  89. move-result-object v0
  90. iput-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->openClientSockets:Ljava/util/Set;
  91. new-instance v0, Ljava/util/concurrent/ConcurrentHashMap;
  92. invoke-direct {v0}, Ljava/util/concurrent/ConcurrentHashMap;-><init>()V
  93. invoke-static {v0}, Ljava/util/Collections;->newSetFromMap(Ljava/util/Map;)Ljava/util/Set;
  94. move-result-object v0
  95. iput-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->openConnections:Ljava/util/Set;
  96. new-instance v0, Ljava/util/concurrent/atomic/AtomicInteger;
  97. invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>()V
  98. iput-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->requestCount:Ljava/util/concurrent/atomic/AtomicInteger;
  99. const-wide v0, 0x7fffffffffffffffL
  100. iput-wide v0, p0, Lokhttp3/mockwebserver/MockWebServer;->bodyLimit:J
  101. invoke-static {}, Ljavax/net/ServerSocketFactory;->getDefault()Ljavax/net/ServerSocketFactory;
  102. move-result-object v0
  103. iput-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocketFactory:Ljavax/net/ServerSocketFactory;
  104. new-instance v0, Lokhttp3/mockwebserver/QueueDispatcher;
  105. invoke-direct {v0}, Lokhttp3/mockwebserver/QueueDispatcher;-><init>()V
  106. iput-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  107. const/4 v0, -0x1
  108. iput v0, p0, Lokhttp3/mockwebserver/MockWebServer;->port:I
  109. const/4 v0, 0x1
  110. iput-boolean v0, p0, Lokhttp3/mockwebserver/MockWebServer;->protocolNegotiationEnabled:Z
  111. const/4 v1, 0x2
  112. new-array v1, v1, [Lokhttp3/Protocol;
  113. sget-object v2, Lokhttp3/Protocol;->HTTP_2:Lokhttp3/Protocol;
  114. const/4 v3, 0x0
  115. aput-object v2, v1, v3
  116. sget-object v2, Lokhttp3/Protocol;->HTTP_1_1:Lokhttp3/Protocol;
  117. aput-object v2, v1, v0
  118. invoke-static {v1}, Lokhttp3/internal/Util;->immutableList([Ljava/lang/Object;)Ljava/util/List;
  119. move-result-object v0
  120. iput-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->protocols:Ljava/util/List;
  121. return-void
  122. .end method
  123. .method static synthetic access$000()Ljava/util/logging/Logger;
  124. .locals 1
  125. sget-object v0, Lokhttp3/mockwebserver/MockWebServer;->logger:Ljava/util/logging/Logger;
  126. return-object v0
  127. .end method
  128. .method static synthetic access$100(Lokhttp3/mockwebserver/MockWebServer;)Ljava/net/ServerSocket;
  129. .locals 0
  130. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocket:Ljava/net/ServerSocket;
  131. return-object p0
  132. .end method
  133. .method static synthetic access$1000(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;)V
  134. .locals 0
  135. .annotation system Ldalvik/annotation/Throws;
  136. value = {
  137. Ljava/lang/Exception;
  138. }
  139. .end annotation
  140. invoke-direct {p0, p1}, Lokhttp3/mockwebserver/MockWebServer;->processHandshakeFailure(Ljava/net/Socket;)V
  141. return-void
  142. .end method
  143. .method static synthetic access$1100(Lokhttp3/mockwebserver/MockWebServer;)Z
  144. .locals 0
  145. iget-boolean p0, p0, Lokhttp3/mockwebserver/MockWebServer;->protocolNegotiationEnabled:Z
  146. return p0
  147. .end method
  148. .method static synthetic access$1200(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/List;
  149. .locals 0
  150. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->protocols:Ljava/util/List;
  151. return-object p0
  152. .end method
  153. .method static synthetic access$1400(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;I)Lokhttp3/mockwebserver/RecordedRequest;
  154. .locals 0
  155. .annotation system Ldalvik/annotation/Throws;
  156. value = {
  157. Ljava/io/IOException;
  158. }
  159. .end annotation
  160. invoke-direct {p0, p1, p2, p3, p4}, Lokhttp3/mockwebserver/MockWebServer;->readRequest(Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;I)Lokhttp3/mockwebserver/RecordedRequest;
  161. move-result-object p0
  162. return-object p0
  163. .end method
  164. .method static synthetic access$1500(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/concurrent/atomic/AtomicInteger;
  165. .locals 0
  166. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->requestCount:Ljava/util/concurrent/atomic/AtomicInteger;
  167. return-object p0
  168. .end method
  169. .method static synthetic access$1600(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/concurrent/BlockingQueue;
  170. .locals 0
  171. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->requestQueue:Ljava/util/concurrent/BlockingQueue;
  172. return-object p0
  173. .end method
  174. .method static synthetic access$1700(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;Lokhttp3/mockwebserver/RecordedRequest;Lokhttp3/mockwebserver/MockResponse;)V
  175. .locals 0
  176. .annotation system Ldalvik/annotation/Throws;
  177. value = {
  178. Ljava/io/IOException;
  179. }
  180. .end annotation
  181. invoke-direct/range {p0 .. p5}, Lokhttp3/mockwebserver/MockWebServer;->handleWebSocketUpgrade(Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;Lokhttp3/mockwebserver/RecordedRequest;Lokhttp3/mockwebserver/MockResponse;)V
  182. return-void
  183. .end method
  184. .method static synthetic access$1800(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;Lokio/BufferedSink;Lokhttp3/mockwebserver/MockResponse;)V
  185. .locals 0
  186. .annotation system Ldalvik/annotation/Throws;
  187. value = {
  188. Ljava/io/IOException;
  189. }
  190. .end annotation
  191. invoke-direct {p0, p1, p2, p3}, Lokhttp3/mockwebserver/MockWebServer;->writeHttpResponse(Ljava/net/Socket;Lokio/BufferedSink;Lokhttp3/mockwebserver/MockResponse;)V
  192. return-void
  193. .end method
  194. .method static synthetic access$200(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/Set;
  195. .locals 0
  196. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->openClientSockets:Ljava/util/Set;
  197. return-object p0
  198. .end method
  199. .method static synthetic access$2100(Lokhttp3/mockwebserver/MockWebServer;Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  200. .locals 0
  201. .annotation system Ldalvik/annotation/Throws;
  202. value = {
  203. Ljava/io/IOException;
  204. }
  205. .end annotation
  206. invoke-direct/range {p0 .. p7}, Lokhttp3/mockwebserver/MockWebServer;->throttledTransfer(Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  207. return-void
  208. .end method
  209. .method static synthetic access$2200(Lokhttp3/mockwebserver/MockWebServer;J)V
  210. .locals 0
  211. invoke-direct {p0, p1, p2}, Lokhttp3/mockwebserver/MockWebServer;->sleepIfDelayed(J)V
  212. return-void
  213. .end method
  214. .method static synthetic access$300(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/Set;
  215. .locals 0
  216. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->openConnections:Ljava/util/Set;
  217. return-object p0
  218. .end method
  219. .method static synthetic access$400(Lokhttp3/mockwebserver/MockWebServer;)Lokhttp3/mockwebserver/Dispatcher;
  220. .locals 0
  221. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  222. return-object p0
  223. .end method
  224. .method static synthetic access$500(Lokhttp3/mockwebserver/MockWebServer;)Ljava/util/concurrent/ExecutorService;
  225. .locals 0
  226. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->executor:Ljava/util/concurrent/ExecutorService;
  227. return-object p0
  228. .end method
  229. .method static synthetic access$600(Lokhttp3/mockwebserver/MockWebServer;ILjava/net/Socket;)V
  230. .locals 0
  231. .annotation system Ldalvik/annotation/Throws;
  232. value = {
  233. Ljava/lang/InterruptedException;
  234. }
  235. .end annotation
  236. invoke-direct {p0, p1, p2}, Lokhttp3/mockwebserver/MockWebServer;->dispatchBookkeepingRequest(ILjava/net/Socket;)V
  237. return-void
  238. .end method
  239. .method static synthetic access$700(Lokhttp3/mockwebserver/MockWebServer;Ljava/net/Socket;)V
  240. .locals 0
  241. invoke-direct {p0, p1}, Lokhttp3/mockwebserver/MockWebServer;->serveConnection(Ljava/net/Socket;)V
  242. return-void
  243. .end method
  244. .method static synthetic access$800(Lokhttp3/mockwebserver/MockWebServer;)Ljavax/net/ssl/SSLSocketFactory;
  245. .locals 0
  246. iget-object p0, p0, Lokhttp3/mockwebserver/MockWebServer;->sslSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
  247. return-object p0
  248. .end method
  249. .method static synthetic access$900(Lokhttp3/mockwebserver/MockWebServer;)Z
  250. .locals 0
  251. iget-boolean p0, p0, Lokhttp3/mockwebserver/MockWebServer;->tunnelProxy:Z
  252. return p0
  253. .end method
  254. .method private dispatchBookkeepingRequest(ILjava/net/Socket;)V
  255. .locals 10
  256. .annotation system Ldalvik/annotation/Throws;
  257. value = {
  258. Ljava/lang/InterruptedException;
  259. }
  260. .end annotation
  261. new-instance v9, Lokhttp3/mockwebserver/RecordedRequest;
  262. const/4 v1, 0x0
  263. const/4 v2, 0x0
  264. const/4 v3, 0x0
  265. const-wide/16 v4, -0x1
  266. const/4 v6, 0x0
  267. move-object v0, v9
  268. move v7, p1
  269. move-object v8, p2
  270. invoke-direct/range {v0 .. v8}, Lokhttp3/mockwebserver/RecordedRequest;-><init>(Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILjava/net/Socket;)V
  271. iget-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->requestCount:Ljava/util/concurrent/atomic/AtomicInteger;
  272. invoke-virtual {p1}, Ljava/util/concurrent/atomic/AtomicInteger;->incrementAndGet()I
  273. iget-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->requestQueue:Ljava/util/concurrent/BlockingQueue;
  274. invoke-interface {p1, v9}, Ljava/util/concurrent/BlockingQueue;->add(Ljava/lang/Object;)Z
  275. iget-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  276. invoke-virtual {p1, v9}, Lokhttp3/mockwebserver/Dispatcher;->dispatch(Lokhttp3/mockwebserver/RecordedRequest;)Lokhttp3/mockwebserver/MockResponse;
  277. return-void
  278. .end method
  279. .method private handleWebSocketUpgrade(Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;Lokhttp3/mockwebserver/RecordedRequest;Lokhttp3/mockwebserver/MockResponse;)V
  280. .locals 10
  281. .annotation system Ldalvik/annotation/Throws;
  282. value = {
  283. Ljava/io/IOException;
  284. }
  285. .end annotation
  286. const-string v0, "Sec-WebSocket-Key"
  287. invoke-virtual {p4, v0}, Lokhttp3/mockwebserver/RecordedRequest;->getHeader(Ljava/lang/String;)Ljava/lang/String;
  288. move-result-object v0
  289. invoke-static {v0}, Lokhttp3/internal/ws/WebSocketProtocol;->acceptHeader(Ljava/lang/String;)Ljava/lang/String;
  290. move-result-object v0
  291. const-string v1, "Sec-WebSocket-Accept"
  292. invoke-virtual {p5, v1, v0}, Lokhttp3/mockwebserver/MockResponse;->setHeader(Ljava/lang/String;Ljava/lang/Object;)Lokhttp3/mockwebserver/MockResponse;
  293. invoke-direct {p0, p1, p3, p5}, Lokhttp3/mockwebserver/MockWebServer;->writeHttpResponse(Ljava/net/Socket;Lokio/BufferedSink;Lokhttp3/mockwebserver/MockResponse;)V
  294. invoke-virtual {p4}, Lokhttp3/mockwebserver/RecordedRequest;->getTlsVersion()Lokhttp3/TlsVersion;
  295. move-result-object p1
  296. if-eqz p1, :cond_0
  297. const-string p1, "https"
  298. goto :goto_0
  299. :cond_0
  300. const-string p1, "http"
  301. :goto_0
  302. const-string v0, "Host"
  303. invoke-virtual {p4, v0}, Lokhttp3/mockwebserver/RecordedRequest;->getHeader(Ljava/lang/String;)Ljava/lang/String;
  304. move-result-object v0
  305. new-instance v1, Lokhttp3/Request$Builder;
  306. invoke-direct {v1}, Lokhttp3/Request$Builder;-><init>()V
  307. new-instance v2, Ljava/lang/StringBuilder;
  308. invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
  309. invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  310. const-string p1, "://"
  311. invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  312. invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  313. const-string p1, "/"
  314. invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  315. invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  316. move-result-object p1
  317. invoke-virtual {v1, p1}, Lokhttp3/Request$Builder;->url(Ljava/lang/String;)Lokhttp3/Request$Builder;
  318. move-result-object p1
  319. invoke-virtual {p4}, Lokhttp3/mockwebserver/RecordedRequest;->getHeaders()Lokhttp3/Headers;
  320. move-result-object v0
  321. invoke-virtual {p1, v0}, Lokhttp3/Request$Builder;->headers(Lokhttp3/Headers;)Lokhttp3/Request$Builder;
  322. move-result-object p1
  323. invoke-virtual {p1}, Lokhttp3/Request$Builder;->build()Lokhttp3/Request;
  324. move-result-object p1
  325. new-instance v0, Lokhttp3/Response$Builder;
  326. invoke-direct {v0}, Lokhttp3/Response$Builder;-><init>()V
  327. invoke-virtual {p5}, Lokhttp3/mockwebserver/MockResponse;->getStatus()Ljava/lang/String;
  328. move-result-object v1
  329. const-string v2, " "
  330. invoke-virtual {v1, v2}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;
  331. move-result-object v1
  332. const/4 v3, 0x1
  333. aget-object v1, v1, v3
  334. invoke-static {v1}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
  335. move-result v1
  336. invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->code(I)Lokhttp3/Response$Builder;
  337. move-result-object v0
  338. invoke-virtual {p5}, Lokhttp3/mockwebserver/MockResponse;->getStatus()Ljava/lang/String;
  339. move-result-object v1
  340. const/4 v4, 0x3
  341. invoke-virtual {v1, v2, v4}, Ljava/lang/String;->split(Ljava/lang/String;I)[Ljava/lang/String;
  342. move-result-object v1
  343. const/4 v2, 0x2
  344. aget-object v1, v1, v2
  345. invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->message(Ljava/lang/String;)Lokhttp3/Response$Builder;
  346. move-result-object v0
  347. invoke-virtual {p5}, Lokhttp3/mockwebserver/MockResponse;->getHeaders()Lokhttp3/Headers;
  348. move-result-object v1
  349. invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->headers(Lokhttp3/Headers;)Lokhttp3/Response$Builder;
  350. move-result-object v0
  351. invoke-virtual {v0, p1}, Lokhttp3/Response$Builder;->request(Lokhttp3/Request;)Lokhttp3/Response$Builder;
  352. move-result-object v0
  353. sget-object v1, Lokhttp3/Protocol;->HTTP_1_1:Lokhttp3/Protocol;
  354. invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->protocol(Lokhttp3/Protocol;)Lokhttp3/Response$Builder;
  355. move-result-object v0
  356. invoke-virtual {v0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
  357. move-result-object v0
  358. new-instance v1, Ljava/util/concurrent/CountDownLatch;
  359. invoke-direct {v1, v3}, Ljava/util/concurrent/CountDownLatch;-><init>(I)V
  360. new-instance v2, Lokhttp3/mockwebserver/MockWebServer$4;
  361. const/4 v6, 0x0
  362. move-object v4, v2
  363. move-object v5, p0
  364. move-object v7, p2
  365. move-object v8, p3
  366. move-object v9, v1
  367. invoke-direct/range {v4 .. v9}, Lokhttp3/mockwebserver/MockWebServer$4;-><init>(Lokhttp3/mockwebserver/MockWebServer;ZLokio/BufferedSource;Lokio/BufferedSink;Ljava/util/concurrent/CountDownLatch;)V
  368. new-instance p3, Lokhttp3/internal/ws/RealWebSocket;
  369. invoke-virtual {p5}, Lokhttp3/mockwebserver/MockResponse;->getWebSocketListener()Lokhttp3/WebSocketListener;
  370. move-result-object v3
  371. new-instance v4, Ljava/security/SecureRandom;
  372. invoke-direct {v4}, Ljava/security/SecureRandom;-><init>()V
  373. invoke-direct {p3, p1, v3, v4}, Lokhttp3/internal/ws/RealWebSocket;-><init>(Lokhttp3/Request;Lokhttp3/WebSocketListener;Ljava/util/Random;)V
  374. invoke-virtual {p5}, Lokhttp3/mockwebserver/MockResponse;->getWebSocketListener()Lokhttp3/WebSocketListener;
  375. move-result-object p1
  376. invoke-virtual {p1, p3, v0}, Lokhttp3/WebSocketListener;->onOpen(Lokhttp3/WebSocket;Lokhttp3/Response;)V
  377. new-instance p1, Ljava/lang/StringBuilder;
  378. invoke-direct {p1}, Ljava/lang/StringBuilder;-><init>()V
  379. const-string p5, "MockWebServer WebSocket "
  380. invoke-virtual {p1, p5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  381. invoke-virtual {p4}, Lokhttp3/mockwebserver/RecordedRequest;->getPath()Ljava/lang/String;
  382. move-result-object p4
  383. invoke-virtual {p1, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  384. invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  385. move-result-object p1
  386. const-wide/16 p4, 0x0
  387. invoke-virtual {p3, p1, p4, p5, v2}, Lokhttp3/internal/ws/RealWebSocket;->initReaderAndWriter(Ljava/lang/String;JLokhttp3/internal/ws/RealWebSocket$Streams;)V
  388. :try_start_0
  389. invoke-virtual {p3}, Lokhttp3/internal/ws/RealWebSocket;->loopReader()V
  390. :try_end_0
  391. .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
  392. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  393. :try_start_1
  394. invoke-virtual {v1}, Ljava/util/concurrent/CountDownLatch;->await()V
  395. :try_end_1
  396. .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_1
  397. .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
  398. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  399. goto :goto_1
  400. :catchall_0
  401. move-exception p1
  402. goto :goto_2
  403. :catch_0
  404. move-exception p1
  405. const/4 p4, 0x0
  406. :try_start_2
  407. invoke-virtual {p3, p1, p4}, Lokhttp3/internal/ws/RealWebSocket;->failWebSocket(Ljava/lang/Exception;Lokhttp3/Response;)V
  408. :try_end_2
  409. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  410. :catch_1
  411. :goto_1
  412. invoke-static {p2}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
  413. return-void
  414. :goto_2
  415. invoke-static {p2}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
  416. throw p1
  417. .end method
  418. .method private processHandshakeFailure(Ljava/net/Socket;)V
  419. .locals 5
  420. .annotation system Ldalvik/annotation/Throws;
  421. value = {
  422. Ljava/lang/Exception;
  423. }
  424. .end annotation
  425. const-string v0, "TLS"
  426. invoke-static {v0}, Ljavax/net/ssl/SSLContext;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;
  427. move-result-object v0
  428. const/4 v1, 0x1
  429. new-array v2, v1, [Ljavax/net/ssl/TrustManager;
  430. sget-object v3, Lokhttp3/mockwebserver/MockWebServer;->UNTRUSTED_TRUST_MANAGER:Ljavax/net/ssl/X509TrustManager;
  431. const/4 v4, 0x0
  432. aput-object v3, v2, v4
  433. new-instance v3, Ljava/security/SecureRandom;
  434. invoke-direct {v3}, Ljava/security/SecureRandom;-><init>()V
  435. const/4 v4, 0x0
  436. invoke-virtual {v0, v4, v2, v3}, Ljavax/net/ssl/SSLContext;->init([Ljavax/net/ssl/KeyManager;[Ljavax/net/ssl/TrustManager;Ljava/security/SecureRandom;)V
  437. invoke-virtual {v0}, Ljavax/net/ssl/SSLContext;->getSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
  438. move-result-object v0
  439. invoke-virtual {p1}, Ljava/net/Socket;->getInetAddress()Ljava/net/InetAddress;
  440. move-result-object v2
  441. invoke-virtual {v2}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;
  442. move-result-object v2
  443. invoke-virtual {p1}, Ljava/net/Socket;->getPort()I
  444. move-result v3
  445. invoke-virtual {v0, p1, v2, v3, v1}, Ljavax/net/ssl/SSLSocketFactory;->createSocket(Ljava/net/Socket;Ljava/lang/String;IZ)Ljava/net/Socket;
  446. move-result-object p1
  447. check-cast p1, Ljavax/net/ssl/SSLSocket;
  448. :try_start_0
  449. invoke-virtual {p1}, Ljavax/net/ssl/SSLSocket;->startHandshake()V
  450. new-instance v0, Ljava/lang/AssertionError;
  451. invoke-direct {v0}, Ljava/lang/AssertionError;-><init>()V
  452. throw v0
  453. :try_end_0
  454. .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
  455. :catch_0
  456. invoke-virtual {p1}, Ljavax/net/ssl/SSLSocket;->close()V
  457. return-void
  458. .end method
  459. .method private readEmptyLine(Lokio/BufferedSource;)V
  460. .locals 3
  461. .annotation system Ldalvik/annotation/Throws;
  462. value = {
  463. Ljava/io/IOException;
  464. }
  465. .end annotation
  466. invoke-interface {p1}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  467. move-result-object p1
  468. invoke-virtual {p1}, Ljava/lang/String;->length()I
  469. move-result v0
  470. if-nez v0, :cond_0
  471. return-void
  472. :cond_0
  473. new-instance v0, Ljava/lang/IllegalStateException;
  474. new-instance v1, Ljava/lang/StringBuilder;
  475. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  476. const-string v2, "Expected empty but was: "
  477. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  478. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  479. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  480. move-result-object p1
  481. invoke-direct {v0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  482. throw v0
  483. .end method
  484. .method private readRequest(Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;I)Lokhttp3/mockwebserver/RecordedRequest;
  485. .locals 18
  486. .annotation system Ldalvik/annotation/Throws;
  487. value = {
  488. Ljava/io/IOException;
  489. }
  490. .end annotation
  491. move-object/from16 v8, p0
  492. move-object/from16 v9, p2
  493. move-object/from16 v0, p3
  494. const/4 v1, 0x0
  495. :try_start_0
  496. invoke-interface/range {p2 .. p2}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  497. move-result-object v10
  498. :try_end_0
  499. .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
  500. invoke-virtual {v10}, Ljava/lang/String;->length()I
  501. move-result v2
  502. if-nez v2, :cond_0
  503. return-object v1
  504. :cond_0
  505. new-instance v11, Lokhttp3/Headers$Builder;
  506. invoke-direct {v11}, Lokhttp3/Headers$Builder;-><init>()V
  507. const-wide/16 v1, -0x1
  508. const/4 v12, 0x0
  509. move-wide v5, v1
  510. const/4 v3, 0x0
  511. const/4 v4, 0x0
  512. :cond_1
  513. :goto_0
  514. invoke-interface/range {p2 .. p2}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  515. move-result-object v7
  516. invoke-virtual {v7}, Ljava/lang/String;->length()I
  517. move-result v13
  518. if-eqz v13, :cond_4
  519. sget-object v13, Lokhttp3/internal/Internal;->instance:Lokhttp3/internal/Internal;
  520. invoke-virtual {v13, v11, v7}, Lokhttp3/internal/Internal;->addLenient(Lokhttp3/Headers$Builder;Ljava/lang/String;)V
  521. sget-object v13, Ljava/util/Locale;->US:Ljava/util/Locale;
  522. invoke-virtual {v7, v13}, Ljava/lang/String;->toLowerCase(Ljava/util/Locale;)Ljava/lang/String;
  523. move-result-object v13
  524. cmp-long v15, v5, v1
  525. if-nez v15, :cond_2
  526. const-string v15, "content-length:"
  527. invoke-virtual {v13, v15}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  528. move-result v15
  529. if-eqz v15, :cond_2
  530. const/16 v5, 0xf
  531. invoke-virtual {v7, v5}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  532. move-result-object v5
  533. invoke-virtual {v5}, Ljava/lang/String;->trim()Ljava/lang/String;
  534. move-result-object v5
  535. invoke-static {v5}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J
  536. move-result-wide v5
  537. :cond_2
  538. const-string v7, "transfer-encoding:"
  539. invoke-virtual {v13, v7}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  540. move-result v7
  541. if-eqz v7, :cond_3
  542. const/16 v7, 0x12
  543. invoke-virtual {v13, v7}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  544. move-result-object v7
  545. invoke-virtual {v7}, Ljava/lang/String;->trim()Ljava/lang/String;
  546. move-result-object v7
  547. const-string v15, "chunked"
  548. invoke-virtual {v7, v15}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  549. move-result v7
  550. if-eqz v7, :cond_3
  551. const/4 v4, 0x1
  552. :cond_3
  553. const-string v7, "expect:"
  554. invoke-virtual {v13, v7}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  555. move-result v7
  556. if-eqz v7, :cond_1
  557. const/4 v7, 0x7
  558. invoke-virtual {v13, v7}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  559. move-result-object v7
  560. invoke-virtual {v7}, Ljava/lang/String;->trim()Ljava/lang/String;
  561. move-result-object v7
  562. const-string v13, "100-continue"
  563. invoke-virtual {v7, v13}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  564. move-result v7
  565. if-eqz v7, :cond_1
  566. const/4 v3, 0x1
  567. goto :goto_0
  568. :cond_4
  569. if-eqz v3, :cond_5
  570. iget-object v3, v8, Lokhttp3/mockwebserver/MockWebServer;->dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  571. invoke-virtual {v3}, Lokhttp3/mockwebserver/Dispatcher;->peek()Lokhttp3/mockwebserver/MockResponse;
  572. move-result-object v3
  573. invoke-virtual {v3}, Lokhttp3/mockwebserver/MockResponse;->getSocketPolicy()Lokhttp3/mockwebserver/SocketPolicy;
  574. move-result-object v3
  575. sget-object v7, Lokhttp3/mockwebserver/SocketPolicy;->EXPECT_CONTINUE:Lokhttp3/mockwebserver/SocketPolicy;
  576. if-ne v3, v7, :cond_5
  577. const-string v3, "HTTP/1.1 100 Continue\r\n"
  578. invoke-interface {v0, v3}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  579. const-string v3, "Content-Length: 0\r\n"
  580. invoke-interface {v0, v3}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  581. const-string v3, "\r\n"
  582. invoke-interface {v0, v3}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  583. invoke-interface/range {p3 .. p3}, Lokio/BufferedSink;->flush()V
  584. :cond_5
  585. new-instance v13, Lokhttp3/mockwebserver/MockWebServer$TruncatingBuffer;
  586. iget-wide v14, v8, Lokhttp3/mockwebserver/MockWebServer;->bodyLimit:J
  587. invoke-direct {v13, v14, v15}, Lokhttp3/mockwebserver/MockWebServer$TruncatingBuffer;-><init>(J)V
  588. new-instance v14, Ljava/util/ArrayList;
  589. invoke-direct {v14}, Ljava/util/ArrayList;-><init>()V
  590. iget-object v0, v8, Lokhttp3/mockwebserver/MockWebServer;->dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  591. invoke-virtual {v0}, Lokhttp3/mockwebserver/Dispatcher;->peek()Lokhttp3/mockwebserver/MockResponse;
  592. move-result-object v15
  593. cmp-long v0, v5, v1
  594. if-eqz v0, :cond_7
  595. const-wide/16 v0, 0x0
  596. cmp-long v2, v5, v0
  597. if-lez v2, :cond_6
  598. const/16 v16, 0x1
  599. goto :goto_1
  600. :cond_6
  601. const/16 v16, 0x0
  602. :goto_1
  603. invoke-static {v13}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
  604. move-result-object v4
  605. const/4 v7, 0x1
  606. move-object/from16 v0, p0
  607. move-object v1, v15
  608. move-object/from16 v2, p1
  609. move-object/from16 v3, p2
  610. invoke-direct/range {v0 .. v7}, Lokhttp3/mockwebserver/MockWebServer;->throttledTransfer(Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  611. goto :goto_3
  612. :cond_7
  613. if-eqz v4, :cond_9
  614. :goto_2
  615. invoke-interface/range {p2 .. p2}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  616. move-result-object v0
  617. invoke-virtual {v0}, Ljava/lang/String;->trim()Ljava/lang/String;
  618. move-result-object v0
  619. const/16 v1, 0x10
  620. invoke-static {v0, v1}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;I)I
  621. move-result v0
  622. if-nez v0, :cond_8
  623. invoke-direct {v8, v9}, Lokhttp3/mockwebserver/MockWebServer;->readEmptyLine(Lokio/BufferedSource;)V
  624. const/16 v16, 0x1
  625. goto :goto_3
  626. :cond_8
  627. invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  628. move-result-object v1
  629. invoke-interface {v14, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  630. invoke-static {v13}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
  631. move-result-object v4
  632. int-to-long v5, v0
  633. const/4 v7, 0x1
  634. move-object/from16 v0, p0
  635. move-object v1, v15
  636. move-object/from16 v2, p1
  637. move-object/from16 v3, p2
  638. invoke-direct/range {v0 .. v7}, Lokhttp3/mockwebserver/MockWebServer;->throttledTransfer(Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  639. invoke-direct {v8, v9}, Lokhttp3/mockwebserver/MockWebServer;->readEmptyLine(Lokio/BufferedSource;)V
  640. goto :goto_2
  641. :cond_9
  642. const/16 v16, 0x0
  643. :goto_3
  644. const/16 v0, 0x20
  645. invoke-virtual {v10, v0}, Ljava/lang/String;->indexOf(I)I
  646. move-result v0
  647. invoke-virtual {v10, v12, v0}, Ljava/lang/String;->substring(II)Ljava/lang/String;
  648. move-result-object v0
  649. if-eqz v16, :cond_b
  650. invoke-static {v0}, Lokhttp3/internal/http/HttpMethod;->permitsRequestBody(Ljava/lang/String;)Z
  651. move-result v0
  652. if-eqz v0, :cond_a
  653. goto :goto_4
  654. :cond_a
  655. new-instance v0, Ljava/lang/IllegalArgumentException;
  656. new-instance v1, Ljava/lang/StringBuilder;
  657. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  658. const-string v2, "Request must not have a body: "
  659. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  660. invoke-virtual {v1, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  661. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  662. move-result-object v1
  663. invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  664. throw v0
  665. :cond_b
  666. :goto_4
  667. new-instance v0, Lokhttp3/mockwebserver/RecordedRequest;
  668. invoke-virtual {v11}, Lokhttp3/Headers$Builder;->build()Lokhttp3/Headers;
  669. move-result-object v11
  670. invoke-static {v13}, Lokhttp3/mockwebserver/MockWebServer$TruncatingBuffer;->access$1900(Lokhttp3/mockwebserver/MockWebServer$TruncatingBuffer;)J
  671. move-result-wide v1
  672. invoke-static {v13}, Lokhttp3/mockwebserver/MockWebServer$TruncatingBuffer;->access$2000(Lokhttp3/mockwebserver/MockWebServer$TruncatingBuffer;)Lokio/Buffer;
  673. move-result-object v15
  674. move-object v9, v0
  675. move-object v12, v14
  676. move-wide v13, v1
  677. move/from16 v16, p4
  678. move-object/from16 v17, p1
  679. invoke-direct/range {v9 .. v17}, Lokhttp3/mockwebserver/RecordedRequest;-><init>(Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILjava/net/Socket;)V
  680. return-object v0
  681. :catch_0
  682. return-object v1
  683. .end method
  684. .method private serveConnection(Ljava/net/Socket;)V
  685. .locals 5
  686. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->executor:Ljava/util/concurrent/ExecutorService;
  687. new-instance v1, Lokhttp3/mockwebserver/MockWebServer$3;
  688. const/4 v2, 0x1
  689. new-array v2, v2, [Ljava/lang/Object;
  690. invoke-virtual {p1}, Ljava/net/Socket;->getRemoteSocketAddress()Ljava/net/SocketAddress;
  691. move-result-object v3
  692. const/4 v4, 0x0
  693. aput-object v3, v2, v4
  694. const-string v3, "MockWebServer %s"
  695. invoke-direct {v1, p0, v3, v2, p1}, Lokhttp3/mockwebserver/MockWebServer$3;-><init>(Lokhttp3/mockwebserver/MockWebServer;Ljava/lang/String;[Ljava/lang/Object;Ljava/net/Socket;)V
  696. invoke-interface {v0, v1}, Ljava/util/concurrent/ExecutorService;->execute(Ljava/lang/Runnable;)V
  697. return-void
  698. .end method
  699. .method private sleepIfDelayed(J)V
  700. .locals 3
  701. const-wide/16 v0, 0x0
  702. cmp-long v2, p1, v0
  703. if-eqz v2, :cond_0
  704. :try_start_0
  705. invoke-static {p1, p2}, Ljava/lang/Thread;->sleep(J)V
  706. :try_end_0
  707. .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0
  708. goto :goto_0
  709. :catch_0
  710. move-exception p1
  711. new-instance p2, Ljava/lang/AssertionError;
  712. invoke-direct {p2, p1}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  713. throw p2
  714. :cond_0
  715. :goto_0
  716. return-void
  717. .end method
  718. .method private declared-synchronized start(Ljava/net/InetSocketAddress;)V
  719. .locals 5
  720. .annotation system Ldalvik/annotation/Throws;
  721. value = {
  722. Ljava/io/IOException;
  723. }
  724. .end annotation
  725. monitor-enter p0
  726. :try_start_0
  727. iget-boolean v0, p0, Lokhttp3/mockwebserver/MockWebServer;->started:Z
  728. if-nez v0, :cond_1
  729. const/4 v0, 0x1
  730. iput-boolean v0, p0, Lokhttp3/mockwebserver/MockWebServer;->started:Z
  731. const-string v1, "MockWebServer"
  732. const/4 v2, 0x0
  733. invoke-static {v1, v2}, Lokhttp3/internal/Util;->threadFactory(Ljava/lang/String;Z)Ljava/util/concurrent/ThreadFactory;
  734. move-result-object v1
  735. invoke-static {v1}, Ljava/util/concurrent/Executors;->newCachedThreadPool(Ljava/util/concurrent/ThreadFactory;)Ljava/util/concurrent/ExecutorService;
  736. move-result-object v1
  737. iput-object v1, p0, Lokhttp3/mockwebserver/MockWebServer;->executor:Ljava/util/concurrent/ExecutorService;
  738. iput-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->inetSocketAddress:Ljava/net/InetSocketAddress;
  739. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocketFactory:Ljavax/net/ServerSocketFactory;
  740. invoke-virtual {v1}, Ljavax/net/ServerSocketFactory;->createServerSocket()Ljava/net/ServerSocket;
  741. move-result-object v1
  742. iput-object v1, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocket:Ljava/net/ServerSocket;
  743. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocket:Ljava/net/ServerSocket;
  744. invoke-virtual {p1}, Ljava/net/InetSocketAddress;->getPort()I
  745. move-result v3
  746. if-eqz v3, :cond_0
  747. const/4 v3, 0x1
  748. goto :goto_0
  749. :cond_0
  750. const/4 v3, 0x0
  751. :goto_0
  752. invoke-virtual {v1, v3}, Ljava/net/ServerSocket;->setReuseAddress(Z)V
  753. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocket:Ljava/net/ServerSocket;
  754. const/16 v3, 0x32
  755. invoke-virtual {v1, p1, v3}, Ljava/net/ServerSocket;->bind(Ljava/net/SocketAddress;I)V
  756. iget-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocket:Ljava/net/ServerSocket;
  757. invoke-virtual {p1}, Ljava/net/ServerSocket;->getLocalPort()I
  758. move-result p1
  759. iput p1, p0, Lokhttp3/mockwebserver/MockWebServer;->port:I
  760. iget-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->executor:Ljava/util/concurrent/ExecutorService;
  761. new-instance v1, Lokhttp3/mockwebserver/MockWebServer$2;
  762. const-string v3, "MockWebServer %s"
  763. new-array v0, v0, [Ljava/lang/Object;
  764. iget v4, p0, Lokhttp3/mockwebserver/MockWebServer;->port:I
  765. invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  766. move-result-object v4
  767. aput-object v4, v0, v2
  768. invoke-direct {v1, p0, v3, v0}, Lokhttp3/mockwebserver/MockWebServer$2;-><init>(Lokhttp3/mockwebserver/MockWebServer;Ljava/lang/String;[Ljava/lang/Object;)V
  769. invoke-interface {p1, v1}, Ljava/util/concurrent/ExecutorService;->execute(Ljava/lang/Runnable;)V
  770. :try_end_0
  771. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  772. monitor-exit p0
  773. return-void
  774. :cond_1
  775. :try_start_1
  776. new-instance p1, Ljava/lang/IllegalStateException;
  777. const-string v0, "start() already called"
  778. invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  779. throw p1
  780. :try_end_1
  781. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  782. :catchall_0
  783. move-exception p1
  784. monitor-exit p0
  785. throw p1
  786. .end method
  787. .method private throttledTransfer(Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  788. .locals 20
  789. .annotation system Ldalvik/annotation/Throws;
  790. value = {
  791. Ljava/io/IOException;
  792. }
  793. .end annotation
  794. const-wide/16 v0, 0x0
  795. cmp-long v2, p5, v0
  796. if-nez v2, :cond_0
  797. return-void
  798. :cond_0
  799. new-instance v2, Lokio/Buffer;
  800. invoke-direct {v2}, Lokio/Buffer;-><init>()V
  801. invoke-virtual/range {p1 .. p1}, Lokhttp3/mockwebserver/MockResponse;->getThrottleBytesPerPeriod()J
  802. move-result-wide v3
  803. sget-object v5, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
  804. move-object/from16 v6, p1
  805. invoke-virtual {v6, v5}, Lokhttp3/mockwebserver/MockResponse;->getThrottlePeriod(Ljava/util/concurrent/TimeUnit;)J
  806. move-result-wide v7
  807. const-wide/16 v9, 0x2
  808. div-long v9, p5, v9
  809. const/4 v5, 0x1
  810. const/4 v11, 0x0
  811. invoke-virtual/range {p1 .. p1}, Lokhttp3/mockwebserver/MockResponse;->getSocketPolicy()Lokhttp3/mockwebserver/SocketPolicy;
  812. move-result-object v6
  813. if-eqz p7, :cond_1
  814. sget-object v12, Lokhttp3/mockwebserver/SocketPolicy;->DISCONNECT_DURING_REQUEST_BODY:Lokhttp3/mockwebserver/SocketPolicy;
  815. if-ne v6, v12, :cond_2
  816. goto :goto_0
  817. :cond_1
  818. sget-object v12, Lokhttp3/mockwebserver/SocketPolicy;->DISCONNECT_DURING_RESPONSE_BODY:Lokhttp3/mockwebserver/SocketPolicy;
  819. if-ne v6, v12, :cond_2
  820. goto :goto_0
  821. :cond_2
  822. const/4 v5, 0x0
  823. :goto_0
  824. move-wide/from16 v12, p5
  825. :goto_1
  826. invoke-virtual/range {p2 .. p2}, Ljava/net/Socket;->isClosed()Z
  827. move-result v6
  828. if-nez v6, :cond_9
  829. const/4 v6, 0x0
  830. :goto_2
  831. int-to-long v14, v6
  832. cmp-long v6, v14, v3
  833. if-gez v6, :cond_7
  834. sub-long v0, v3, v14
  835. invoke-static {v12, v13, v0, v1}, Ljava/lang/Math;->min(JJ)J
  836. move-result-wide v0
  837. move-wide/from16 v16, v3
  838. if-eqz v5, :cond_3
  839. sub-long v3, v12, v9
  840. invoke-static {v0, v1, v3, v4}, Ljava/lang/Math;->min(JJ)J
  841. move-result-wide v0
  842. :cond_3
  843. move-wide v3, v0
  844. move-object/from16 v0, p3
  845. invoke-interface {v0, v2, v3, v4}, Lokio/Source;->read(Lokio/Buffer;J)J
  846. move-result-wide v3
  847. const-wide/16 v18, -0x1
  848. cmp-long v1, v3, v18
  849. if-nez v1, :cond_4
  850. return-void
  851. :cond_4
  852. move-object/from16 v1, p4
  853. invoke-interface {v1, v2, v3, v4}, Lokio/Sink;->write(Lokio/Buffer;J)V
  854. invoke-interface/range {p4 .. p4}, Lokio/BufferedSink;->flush()V
  855. add-long/2addr v14, v3
  856. long-to-int v6, v14
  857. sub-long/2addr v12, v3
  858. if-eqz v5, :cond_5
  859. cmp-long v3, v12, v9
  860. if-nez v3, :cond_5
  861. invoke-virtual/range {p2 .. p2}, Ljava/net/Socket;->close()V
  862. return-void
  863. :cond_5
  864. const-wide/16 v3, 0x0
  865. cmp-long v14, v12, v3
  866. if-nez v14, :cond_6
  867. return-void
  868. :cond_6
  869. move-wide v0, v3
  870. move-wide/from16 v3, v16
  871. goto :goto_2
  872. :cond_7
  873. move-wide/from16 v16, v3
  874. move-wide v3, v0
  875. move-object/from16 v0, p3
  876. move-object/from16 v1, p4
  877. cmp-long v6, v7, v3
  878. if-eqz v6, :cond_8
  879. :try_start_0
  880. invoke-static {v7, v8}, Ljava/lang/Thread;->sleep(J)V
  881. :try_end_0
  882. .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0
  883. goto :goto_3
  884. :catch_0
  885. new-instance v0, Ljava/lang/AssertionError;
  886. invoke-direct {v0}, Ljava/lang/AssertionError;-><init>()V
  887. throw v0
  888. :cond_8
  889. :goto_3
  890. move-wide v0, v3
  891. move-wide/from16 v3, v16
  892. goto :goto_1
  893. :cond_9
  894. return-void
  895. .end method
  896. .method private writeHttpResponse(Ljava/net/Socket;Lokio/BufferedSink;Lokhttp3/mockwebserver/MockResponse;)V
  897. .locals 12
  898. .annotation system Ldalvik/annotation/Throws;
  899. value = {
  900. Ljava/io/IOException;
  901. }
  902. .end annotation
  903. sget-object v0, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
  904. invoke-virtual {p3, v0}, Lokhttp3/mockwebserver/MockResponse;->getBodyDelay(Ljava/util/concurrent/TimeUnit;)J
  905. move-result-wide v0
  906. invoke-direct {p0, v0, v1}, Lokhttp3/mockwebserver/MockWebServer;->sleepIfDelayed(J)V
  907. invoke-virtual {p3}, Lokhttp3/mockwebserver/MockResponse;->getStatus()Ljava/lang/String;
  908. move-result-object v0
  909. invoke-interface {p2, v0}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  910. const-string v0, "\r\n"
  911. invoke-interface {p2, v0}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  912. invoke-virtual {p3}, Lokhttp3/mockwebserver/MockResponse;->getHeaders()Lokhttp3/Headers;
  913. move-result-object v1
  914. invoke-virtual {v1}, Lokhttp3/Headers;->size()I
  915. move-result v2
  916. const/4 v3, 0x0
  917. :goto_0
  918. if-ge v3, v2, :cond_0
  919. invoke-virtual {v1, v3}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
  920. move-result-object v4
  921. invoke-interface {p2, v4}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  922. const-string v4, ": "
  923. invoke-interface {p2, v4}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  924. invoke-virtual {v1, v3}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
  925. move-result-object v4
  926. invoke-interface {p2, v4}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  927. invoke-interface {p2, v0}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  928. add-int/lit8 v3, v3, 0x1
  929. goto :goto_0
  930. :cond_0
  931. invoke-interface {p2, v0}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  932. invoke-interface {p2}, Lokio/BufferedSink;->flush()V
  933. invoke-virtual {p3}, Lokhttp3/mockwebserver/MockResponse;->getBody()Lokio/Buffer;
  934. move-result-object v7
  935. if-nez v7, :cond_1
  936. return-void
  937. :cond_1
  938. sget-object v0, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
  939. invoke-virtual {p3, v0}, Lokhttp3/mockwebserver/MockResponse;->getBodyDelay(Ljava/util/concurrent/TimeUnit;)J
  940. move-result-wide v0
  941. invoke-direct {p0, v0, v1}, Lokhttp3/mockwebserver/MockWebServer;->sleepIfDelayed(J)V
  942. invoke-virtual {v7}, Lokio/Buffer;->size()J
  943. move-result-wide v9
  944. const/4 v11, 0x0
  945. move-object v4, p0
  946. move-object v5, p3
  947. move-object v6, p1
  948. move-object v8, p2
  949. invoke-direct/range {v4 .. v11}, Lokhttp3/mockwebserver/MockWebServer;->throttledTransfer(Lokhttp3/mockwebserver/MockResponse;Ljava/net/Socket;Lokio/BufferedSource;Lokio/BufferedSink;JZ)V
  950. return-void
  951. .end method
  952. # virtual methods
  953. .method protected declared-synchronized after()V
  954. .locals 4
  955. monitor-enter p0
  956. :try_start_0
  957. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->shutdown()V
  958. :try_end_0
  959. .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
  960. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  961. goto :goto_0
  962. :catchall_0
  963. move-exception v0
  964. goto :goto_1
  965. :catch_0
  966. move-exception v0
  967. :try_start_1
  968. sget-object v1, Lokhttp3/mockwebserver/MockWebServer;->logger:Ljava/util/logging/Logger;
  969. sget-object v2, Ljava/util/logging/Level;->WARNING:Ljava/util/logging/Level;
  970. const-string v3, "MockWebServer shutdown failed"
  971. invoke-virtual {v1, v2, v3, v0}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
  972. :try_end_1
  973. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  974. :goto_0
  975. monitor-exit p0
  976. return-void
  977. :goto_1
  978. monitor-exit p0
  979. throw v0
  980. .end method
  981. .method protected declared-synchronized before()V
  982. .locals 2
  983. monitor-enter p0
  984. :try_start_0
  985. iget-boolean v0, p0, Lokhttp3/mockwebserver/MockWebServer;->started:Z
  986. :try_end_0
  987. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  988. if-eqz v0, :cond_0
  989. monitor-exit p0
  990. return-void
  991. :cond_0
  992. :try_start_1
  993. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->start()V
  994. :try_end_1
  995. .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
  996. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  997. monitor-exit p0
  998. return-void
  999. :catch_0
  1000. move-exception v0
  1001. :try_start_2
  1002. new-instance v1, Ljava/lang/RuntimeException;
  1003. invoke-direct {v1, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/Throwable;)V
  1004. throw v1
  1005. :try_end_2
  1006. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  1007. :catchall_0
  1008. move-exception v0
  1009. monitor-exit p0
  1010. throw v0
  1011. .end method
  1012. .method public close()V
  1013. .locals 0
  1014. .annotation system Ldalvik/annotation/Throws;
  1015. value = {
  1016. Ljava/io/IOException;
  1017. }
  1018. .end annotation
  1019. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->shutdown()V
  1020. return-void
  1021. .end method
  1022. .method public enqueue(Lokhttp3/mockwebserver/MockResponse;)V
  1023. .locals 1
  1024. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  1025. check-cast v0, Lokhttp3/mockwebserver/QueueDispatcher;
  1026. invoke-virtual {p1}, Lokhttp3/mockwebserver/MockResponse;->clone()Lokhttp3/mockwebserver/MockResponse;
  1027. move-result-object p1
  1028. invoke-virtual {v0, p1}, Lokhttp3/mockwebserver/QueueDispatcher;->enqueueResponse(Lokhttp3/mockwebserver/MockResponse;)V
  1029. return-void
  1030. .end method
  1031. .method public getHostName()Ljava/lang/String;
  1032. .locals 1
  1033. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->before()V
  1034. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->inetSocketAddress:Ljava/net/InetSocketAddress;
  1035. invoke-virtual {v0}, Ljava/net/InetSocketAddress;->getAddress()Ljava/net/InetAddress;
  1036. move-result-object v0
  1037. invoke-virtual {v0}, Ljava/net/InetAddress;->getCanonicalHostName()Ljava/lang/String;
  1038. move-result-object v0
  1039. return-object v0
  1040. .end method
  1041. .method public getPort()I
  1042. .locals 1
  1043. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->before()V
  1044. iget v0, p0, Lokhttp3/mockwebserver/MockWebServer;->port:I
  1045. return v0
  1046. .end method
  1047. .method public getRequestCount()I
  1048. .locals 1
  1049. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->requestCount:Ljava/util/concurrent/atomic/AtomicInteger;
  1050. invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicInteger;->get()I
  1051. move-result v0
  1052. return v0
  1053. .end method
  1054. .method public setBodyLimit(J)V
  1055. .locals 0
  1056. iput-wide p1, p0, Lokhttp3/mockwebserver/MockWebServer;->bodyLimit:J
  1057. return-void
  1058. .end method
  1059. .method public setDispatcher(Lokhttp3/mockwebserver/Dispatcher;)V
  1060. .locals 0
  1061. if-eqz p1, :cond_0
  1062. iput-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->dispatcher:Lokhttp3/mockwebserver/Dispatcher;
  1063. return-void
  1064. :cond_0
  1065. new-instance p1, Ljava/lang/NullPointerException;
  1066. invoke-direct {p1}, Ljava/lang/NullPointerException;-><init>()V
  1067. throw p1
  1068. .end method
  1069. .method public setProtocolNegotiationEnabled(Z)V
  1070. .locals 0
  1071. iput-boolean p1, p0, Lokhttp3/mockwebserver/MockWebServer;->protocolNegotiationEnabled:Z
  1072. return-void
  1073. .end method
  1074. .method public setProtocols(Ljava/util/List;)V
  1075. .locals 3
  1076. .annotation system Ldalvik/annotation/Signature;
  1077. value = {
  1078. "(",
  1079. "Ljava/util/List<",
  1080. "Lokhttp3/Protocol;",
  1081. ">;)V"
  1082. }
  1083. .end annotation
  1084. invoke-static {p1}, Lokhttp3/internal/Util;->immutableList(Ljava/util/List;)Ljava/util/List;
  1085. move-result-object p1
  1086. sget-object v0, Lokhttp3/Protocol;->HTTP_1_1:Lokhttp3/Protocol;
  1087. invoke-interface {p1, v0}, Ljava/util/List;->contains(Ljava/lang/Object;)Z
  1088. move-result v0
  1089. if-eqz v0, :cond_1
  1090. const/4 v0, 0x0
  1091. invoke-interface {p1, v0}, Ljava/util/List;->contains(Ljava/lang/Object;)Z
  1092. move-result v0
  1093. if-nez v0, :cond_0
  1094. iput-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->protocols:Ljava/util/List;
  1095. return-void
  1096. :cond_0
  1097. new-instance p1, Ljava/lang/IllegalArgumentException;
  1098. const-string v0, "protocols must not contain null"
  1099. invoke-direct {p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  1100. throw p1
  1101. :cond_1
  1102. new-instance v0, Ljava/lang/IllegalArgumentException;
  1103. new-instance v1, Ljava/lang/StringBuilder;
  1104. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  1105. const-string v2, "protocols doesn\'t contain http/1.1: "
  1106. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  1107. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  1108. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  1109. move-result-object p1
  1110. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  1111. throw v0
  1112. .end method
  1113. .method public setServerSocketFactory(Ljavax/net/ServerSocketFactory;)V
  1114. .locals 1
  1115. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->executor:Ljava/util/concurrent/ExecutorService;
  1116. if-nez v0, :cond_0
  1117. iput-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocketFactory:Ljavax/net/ServerSocketFactory;
  1118. return-void
  1119. :cond_0
  1120. new-instance p1, Ljava/lang/IllegalStateException;
  1121. const-string v0, "setServerSocketFactory() must be called before start()"
  1122. invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  1123. throw p1
  1124. .end method
  1125. .method public declared-synchronized shutdown()V
  1126. .locals 4
  1127. .annotation system Ldalvik/annotation/Throws;
  1128. value = {
  1129. Ljava/io/IOException;
  1130. }
  1131. .end annotation
  1132. monitor-enter p0
  1133. :try_start_0
  1134. iget-boolean v0, p0, Lokhttp3/mockwebserver/MockWebServer;->started:Z
  1135. :try_end_0
  1136. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  1137. if-nez v0, :cond_0
  1138. monitor-exit p0
  1139. return-void
  1140. :cond_0
  1141. :try_start_1
  1142. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocket:Ljava/net/ServerSocket;
  1143. if-eqz v0, :cond_2
  1144. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->serverSocket:Ljava/net/ServerSocket;
  1145. invoke-virtual {v0}, Ljava/net/ServerSocket;->close()V
  1146. :try_end_1
  1147. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  1148. :try_start_2
  1149. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->executor:Ljava/util/concurrent/ExecutorService;
  1150. const-wide/16 v1, 0x5
  1151. sget-object v3, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
  1152. invoke-interface {v0, v1, v2, v3}, Ljava/util/concurrent/ExecutorService;->awaitTermination(JLjava/util/concurrent/TimeUnit;)Z
  1153. move-result v0
  1154. :try_end_2
  1155. .catch Ljava/lang/InterruptedException; {:try_start_2 .. :try_end_2} :catch_0
  1156. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  1157. if-eqz v0, :cond_1
  1158. monitor-exit p0
  1159. return-void
  1160. :cond_1
  1161. :try_start_3
  1162. new-instance v0, Ljava/io/IOException;
  1163. const-string v1, "Gave up waiting for executor to shut down"
  1164. invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  1165. throw v0
  1166. :try_end_3
  1167. .catch Ljava/lang/InterruptedException; {:try_start_3 .. :try_end_3} :catch_0
  1168. .catchall {:try_start_3 .. :try_end_3} :catchall_0
  1169. :catch_0
  1170. :try_start_4
  1171. new-instance v0, Ljava/lang/AssertionError;
  1172. invoke-direct {v0}, Ljava/lang/AssertionError;-><init>()V
  1173. throw v0
  1174. :cond_2
  1175. new-instance v0, Ljava/lang/IllegalStateException;
  1176. const-string v1, "shutdown() before start()"
  1177. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  1178. throw v0
  1179. :try_end_4
  1180. .catchall {:try_start_4 .. :try_end_4} :catchall_0
  1181. :catchall_0
  1182. move-exception v0
  1183. monitor-exit p0
  1184. throw v0
  1185. .end method
  1186. .method public start()V
  1187. .locals 1
  1188. .annotation system Ldalvik/annotation/Throws;
  1189. value = {
  1190. Ljava/io/IOException;
  1191. }
  1192. .end annotation
  1193. const/4 v0, 0x0
  1194. invoke-virtual {p0, v0}, Lokhttp3/mockwebserver/MockWebServer;->start(I)V
  1195. return-void
  1196. .end method
  1197. .method public start(I)V
  1198. .locals 1
  1199. .annotation system Ldalvik/annotation/Throws;
  1200. value = {
  1201. Ljava/io/IOException;
  1202. }
  1203. .end annotation
  1204. const-string v0, "localhost"
  1205. invoke-static {v0}, Ljava/net/InetAddress;->getByName(Ljava/lang/String;)Ljava/net/InetAddress;
  1206. move-result-object v0
  1207. invoke-virtual {p0, v0, p1}, Lokhttp3/mockwebserver/MockWebServer;->start(Ljava/net/InetAddress;I)V
  1208. return-void
  1209. .end method
  1210. .method public start(Ljava/net/InetAddress;I)V
  1211. .locals 1
  1212. .annotation system Ldalvik/annotation/Throws;
  1213. value = {
  1214. Ljava/io/IOException;
  1215. }
  1216. .end annotation
  1217. new-instance v0, Ljava/net/InetSocketAddress;
  1218. invoke-direct {v0, p1, p2}, Ljava/net/InetSocketAddress;-><init>(Ljava/net/InetAddress;I)V
  1219. invoke-direct {p0, v0}, Lokhttp3/mockwebserver/MockWebServer;->start(Ljava/net/InetSocketAddress;)V
  1220. return-void
  1221. .end method
  1222. .method public takeRequest()Lokhttp3/mockwebserver/RecordedRequest;
  1223. .locals 1
  1224. .annotation system Ldalvik/annotation/Throws;
  1225. value = {
  1226. Ljava/lang/InterruptedException;
  1227. }
  1228. .end annotation
  1229. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->requestQueue:Ljava/util/concurrent/BlockingQueue;
  1230. invoke-interface {v0}, Ljava/util/concurrent/BlockingQueue;->take()Ljava/lang/Object;
  1231. move-result-object v0
  1232. check-cast v0, Lokhttp3/mockwebserver/RecordedRequest;
  1233. return-object v0
  1234. .end method
  1235. .method public takeRequest(JLjava/util/concurrent/TimeUnit;)Lokhttp3/mockwebserver/RecordedRequest;
  1236. .locals 1
  1237. .annotation system Ldalvik/annotation/Throws;
  1238. value = {
  1239. Ljava/lang/InterruptedException;
  1240. }
  1241. .end annotation
  1242. iget-object v0, p0, Lokhttp3/mockwebserver/MockWebServer;->requestQueue:Ljava/util/concurrent/BlockingQueue;
  1243. invoke-interface {v0, p1, p2, p3}, Ljava/util/concurrent/BlockingQueue;->poll(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object;
  1244. move-result-object p1
  1245. check-cast p1, Lokhttp3/mockwebserver/RecordedRequest;
  1246. return-object p1
  1247. .end method
  1248. .method public toProxyAddress()Ljava/net/Proxy;
  1249. .locals 3
  1250. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->before()V
  1251. new-instance v0, Ljava/net/InetSocketAddress;
  1252. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer;->inetSocketAddress:Ljava/net/InetSocketAddress;
  1253. invoke-virtual {v1}, Ljava/net/InetSocketAddress;->getAddress()Ljava/net/InetAddress;
  1254. move-result-object v1
  1255. invoke-virtual {v1}, Ljava/net/InetAddress;->getCanonicalHostName()Ljava/lang/String;
  1256. move-result-object v1
  1257. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->getPort()I
  1258. move-result v2
  1259. invoke-direct {v0, v1, v2}, Ljava/net/InetSocketAddress;-><init>(Ljava/lang/String;I)V
  1260. new-instance v1, Ljava/net/Proxy;
  1261. sget-object v2, Ljava/net/Proxy$Type;->HTTP:Ljava/net/Proxy$Type;
  1262. invoke-direct {v1, v2, v0}, Ljava/net/Proxy;-><init>(Ljava/net/Proxy$Type;Ljava/net/SocketAddress;)V
  1263. return-object v1
  1264. .end method
  1265. .method public toString()Ljava/lang/String;
  1266. .locals 2
  1267. new-instance v0, Ljava/lang/StringBuilder;
  1268. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  1269. const-string v1, "MockWebServer["
  1270. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  1271. iget v1, p0, Lokhttp3/mockwebserver/MockWebServer;->port:I
  1272. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  1273. const-string v1, "]"
  1274. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  1275. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  1276. move-result-object v0
  1277. return-object v0
  1278. .end method
  1279. .method public url(Ljava/lang/String;)Lokhttp3/HttpUrl;
  1280. .locals 2
  1281. new-instance v0, Lokhttp3/HttpUrl$Builder;
  1282. invoke-direct {v0}, Lokhttp3/HttpUrl$Builder;-><init>()V
  1283. iget-object v1, p0, Lokhttp3/mockwebserver/MockWebServer;->sslSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
  1284. if-eqz v1, :cond_0
  1285. const-string v1, "https"
  1286. goto :goto_0
  1287. :cond_0
  1288. const-string v1, "http"
  1289. :goto_0
  1290. invoke-virtual {v0, v1}, Lokhttp3/HttpUrl$Builder;->scheme(Ljava/lang/String;)Lokhttp3/HttpUrl$Builder;
  1291. move-result-object v0
  1292. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->getHostName()Ljava/lang/String;
  1293. move-result-object v1
  1294. invoke-virtual {v0, v1}, Lokhttp3/HttpUrl$Builder;->host(Ljava/lang/String;)Lokhttp3/HttpUrl$Builder;
  1295. move-result-object v0
  1296. invoke-virtual {p0}, Lokhttp3/mockwebserver/MockWebServer;->getPort()I
  1297. move-result v1
  1298. invoke-virtual {v0, v1}, Lokhttp3/HttpUrl$Builder;->port(I)Lokhttp3/HttpUrl$Builder;
  1299. move-result-object v0
  1300. invoke-virtual {v0}, Lokhttp3/HttpUrl$Builder;->build()Lokhttp3/HttpUrl;
  1301. move-result-object v0
  1302. invoke-virtual {v0, p1}, Lokhttp3/HttpUrl;->resolve(Ljava/lang/String;)Lokhttp3/HttpUrl;
  1303. move-result-object p1
  1304. return-object p1
  1305. .end method
  1306. .method public useHttps(Ljavax/net/ssl/SSLSocketFactory;Z)V
  1307. .locals 0
  1308. iput-object p1, p0, Lokhttp3/mockwebserver/MockWebServer;->sslSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
  1309. iput-boolean p2, p0, Lokhttp3/mockwebserver/MockWebServer;->tunnelProxy:Z
  1310. return-void
  1311. .end method