Http1Codec.smali 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  1. .class public final Lokhttp3/internal/http1/Http1Codec;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Lokhttp3/internal/http/HttpCodec;
  6. # annotations
  7. .annotation system Ldalvik/annotation/MemberClasses;
  8. value = {
  9. Lokhttp3/internal/http1/Http1Codec$UnknownLengthSource;,
  10. Lokhttp3/internal/http1/Http1Codec$ChunkedSource;,
  11. Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;,
  12. Lokhttp3/internal/http1/Http1Codec$AbstractSource;,
  13. Lokhttp3/internal/http1/Http1Codec$ChunkedSink;,
  14. Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;
  15. }
  16. .end annotation
  17. # static fields
  18. .field private static final STATE_CLOSED:I = 0x6
  19. .field private static final STATE_IDLE:I = 0x0
  20. .field private static final STATE_OPEN_REQUEST_BODY:I = 0x1
  21. .field private static final STATE_OPEN_RESPONSE_BODY:I = 0x4
  22. .field private static final STATE_READING_RESPONSE_BODY:I = 0x5
  23. .field private static final STATE_READ_RESPONSE_HEADERS:I = 0x3
  24. .field private static final STATE_WRITING_REQUEST_BODY:I = 0x2
  25. # instance fields
  26. .field final client:Lokhttp3/OkHttpClient;
  27. .field final sink:Lokio/BufferedSink;
  28. .field final source:Lokio/BufferedSource;
  29. .field state:I
  30. .field final streamAllocation:Lokhttp3/internal/connection/StreamAllocation;
  31. # direct methods
  32. .method public constructor <init>(Lokhttp3/OkHttpClient;Lokhttp3/internal/connection/StreamAllocation;Lokio/BufferedSource;Lokio/BufferedSink;)V
  33. .locals 1
  34. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  35. const/4 v0, 0x0
  36. iput v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  37. iput-object p1, p0, Lokhttp3/internal/http1/Http1Codec;->client:Lokhttp3/OkHttpClient;
  38. iput-object p2, p0, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;
  39. iput-object p3, p0, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/BufferedSource;
  40. iput-object p4, p0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  41. return-void
  42. .end method
  43. # virtual methods
  44. .method public cancel()V
  45. .locals 1
  46. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;
  47. invoke-virtual {v0}, Lokhttp3/internal/connection/StreamAllocation;->connection()Lokhttp3/internal/connection/RealConnection;
  48. move-result-object v0
  49. if-eqz v0, :cond_0
  50. invoke-virtual {v0}, Lokhttp3/internal/connection/RealConnection;->cancel()V
  51. :cond_0
  52. return-void
  53. .end method
  54. .method public createRequestBody(Lokhttp3/Request;J)Lokio/Sink;
  55. .locals 2
  56. const-string v0, "Transfer-Encoding"
  57. invoke-virtual {p1, v0}, Lokhttp3/Request;->header(Ljava/lang/String;)Ljava/lang/String;
  58. move-result-object p1
  59. const-string v0, "chunked"
  60. invoke-virtual {v0, p1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  61. move-result p1
  62. if-eqz p1, :cond_0
  63. invoke-virtual {p0}, Lokhttp3/internal/http1/Http1Codec;->newChunkedSink()Lokio/Sink;
  64. move-result-object p1
  65. return-object p1
  66. :cond_0
  67. const-wide/16 v0, -0x1
  68. cmp-long p1, p2, v0
  69. if-eqz p1, :cond_1
  70. invoke-virtual {p0, p2, p3}, Lokhttp3/internal/http1/Http1Codec;->newFixedLengthSink(J)Lokio/Sink;
  71. move-result-object p1
  72. return-object p1
  73. :cond_1
  74. new-instance p1, Ljava/lang/IllegalStateException;
  75. const-string p2, "Cannot stream a request body without chunked encoding or a known content length!"
  76. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  77. throw p1
  78. .end method
  79. .method detachTimeout(Lokio/ForwardingTimeout;)V
  80. .locals 2
  81. invoke-virtual {p1}, Lokio/ForwardingTimeout;->delegate()Lokio/Timeout;
  82. move-result-object v0
  83. sget-object v1, Lokio/Timeout;->NONE:Lokio/Timeout;
  84. invoke-virtual {p1, v1}, Lokio/ForwardingTimeout;->setDelegate(Lokio/Timeout;)Lokio/ForwardingTimeout;
  85. invoke-virtual {v0}, Lokio/Timeout;->clearDeadline()Lokio/Timeout;
  86. invoke-virtual {v0}, Lokio/Timeout;->clearTimeout()Lokio/Timeout;
  87. return-void
  88. .end method
  89. .method public finishRequest()V
  90. .locals 1
  91. .annotation system Ldalvik/annotation/Throws;
  92. value = {
  93. Ljava/io/IOException;
  94. }
  95. .end annotation
  96. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  97. invoke-interface {v0}, Lokio/BufferedSink;->flush()V
  98. return-void
  99. .end method
  100. .method public flushRequest()V
  101. .locals 1
  102. .annotation system Ldalvik/annotation/Throws;
  103. value = {
  104. Ljava/io/IOException;
  105. }
  106. .end annotation
  107. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  108. invoke-interface {v0}, Lokio/BufferedSink;->flush()V
  109. return-void
  110. .end method
  111. .method public isClosed()Z
  112. .locals 2
  113. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  114. const/4 v1, 0x6
  115. if-ne v0, v1, :cond_0
  116. const/4 v0, 0x1
  117. goto :goto_0
  118. :cond_0
  119. const/4 v0, 0x0
  120. :goto_0
  121. return v0
  122. .end method
  123. .method public newChunkedSink()Lokio/Sink;
  124. .locals 3
  125. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  126. const/4 v1, 0x1
  127. if-ne v0, v1, :cond_0
  128. const/4 v0, 0x2
  129. iput v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  130. new-instance v0, Lokhttp3/internal/http1/Http1Codec$ChunkedSink;
  131. invoke-direct {v0, p0}, Lokhttp3/internal/http1/Http1Codec$ChunkedSink;-><init>(Lokhttp3/internal/http1/Http1Codec;)V
  132. return-object v0
  133. :cond_0
  134. new-instance v0, Ljava/lang/IllegalStateException;
  135. new-instance v1, Ljava/lang/StringBuilder;
  136. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  137. const-string v2, "state: "
  138. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  139. iget v2, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  140. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  141. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  142. move-result-object v1
  143. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  144. throw v0
  145. .end method
  146. .method public newChunkedSource(Lokhttp3/HttpUrl;)Lokio/Source;
  147. .locals 2
  148. .annotation system Ldalvik/annotation/Throws;
  149. value = {
  150. Ljava/io/IOException;
  151. }
  152. .end annotation
  153. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  154. const/4 v1, 0x4
  155. if-ne v0, v1, :cond_0
  156. const/4 v0, 0x5
  157. iput v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  158. new-instance v0, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;
  159. invoke-direct {v0, p0, p1}, Lokhttp3/internal/http1/Http1Codec$ChunkedSource;-><init>(Lokhttp3/internal/http1/Http1Codec;Lokhttp3/HttpUrl;)V
  160. return-object v0
  161. :cond_0
  162. new-instance p1, Ljava/lang/IllegalStateException;
  163. new-instance v0, Ljava/lang/StringBuilder;
  164. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  165. const-string v1, "state: "
  166. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  167. iget v1, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  168. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  169. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  170. move-result-object v0
  171. invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  172. throw p1
  173. .end method
  174. .method public newFixedLengthSink(J)Lokio/Sink;
  175. .locals 2
  176. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  177. const/4 v1, 0x1
  178. if-ne v0, v1, :cond_0
  179. const/4 v0, 0x2
  180. iput v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  181. new-instance v0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;
  182. invoke-direct {v0, p0, p1, p2}, Lokhttp3/internal/http1/Http1Codec$FixedLengthSink;-><init>(Lokhttp3/internal/http1/Http1Codec;J)V
  183. return-object v0
  184. :cond_0
  185. new-instance p1, Ljava/lang/IllegalStateException;
  186. new-instance p2, Ljava/lang/StringBuilder;
  187. invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
  188. const-string v0, "state: "
  189. invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  190. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  191. invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  192. invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  193. move-result-object p2
  194. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  195. throw p1
  196. .end method
  197. .method public newFixedLengthSource(J)Lokio/Source;
  198. .locals 2
  199. .annotation system Ldalvik/annotation/Throws;
  200. value = {
  201. Ljava/io/IOException;
  202. }
  203. .end annotation
  204. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  205. const/4 v1, 0x4
  206. if-ne v0, v1, :cond_0
  207. const/4 v0, 0x5
  208. iput v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  209. new-instance v0, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;
  210. invoke-direct {v0, p0, p1, p2}, Lokhttp3/internal/http1/Http1Codec$FixedLengthSource;-><init>(Lokhttp3/internal/http1/Http1Codec;J)V
  211. return-object v0
  212. :cond_0
  213. new-instance p1, Ljava/lang/IllegalStateException;
  214. new-instance p2, Ljava/lang/StringBuilder;
  215. invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
  216. const-string v0, "state: "
  217. invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  218. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  219. invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  220. invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  221. move-result-object p2
  222. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  223. throw p1
  224. .end method
  225. .method public newUnknownLengthSource()Lokio/Source;
  226. .locals 3
  227. .annotation system Ldalvik/annotation/Throws;
  228. value = {
  229. Ljava/io/IOException;
  230. }
  231. .end annotation
  232. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  233. const/4 v1, 0x4
  234. if-ne v0, v1, :cond_1
  235. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;
  236. if-eqz v0, :cond_0
  237. const/4 v1, 0x5
  238. iput v1, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  239. invoke-virtual {v0}, Lokhttp3/internal/connection/StreamAllocation;->noNewStreams()V
  240. new-instance v0, Lokhttp3/internal/http1/Http1Codec$UnknownLengthSource;
  241. invoke-direct {v0, p0}, Lokhttp3/internal/http1/Http1Codec$UnknownLengthSource;-><init>(Lokhttp3/internal/http1/Http1Codec;)V
  242. return-object v0
  243. :cond_0
  244. new-instance v0, Ljava/lang/IllegalStateException;
  245. const-string v1, "streamAllocation == null"
  246. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  247. throw v0
  248. :cond_1
  249. new-instance v0, Ljava/lang/IllegalStateException;
  250. new-instance v1, Ljava/lang/StringBuilder;
  251. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  252. const-string v2, "state: "
  253. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  254. iget v2, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  255. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  256. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  257. move-result-object v1
  258. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  259. throw v0
  260. .end method
  261. .method public openResponseBody(Lokhttp3/Response;)Lokhttp3/ResponseBody;
  262. .locals 6
  263. .annotation system Ldalvik/annotation/Throws;
  264. value = {
  265. Ljava/io/IOException;
  266. }
  267. .end annotation
  268. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;
  269. iget-object v1, v0, Lokhttp3/internal/connection/StreamAllocation;->eventListener:Lokhttp3/EventListener;
  270. iget-object v0, v0, Lokhttp3/internal/connection/StreamAllocation;->call:Lokhttp3/Call;
  271. invoke-virtual {v1, v0}, Lokhttp3/EventListener;->responseBodyStart(Lokhttp3/Call;)V
  272. const-string v0, "Content-Type"
  273. invoke-virtual {p1, v0}, Lokhttp3/Response;->header(Ljava/lang/String;)Ljava/lang/String;
  274. move-result-object v0
  275. invoke-static {p1}, Lokhttp3/internal/http/HttpHeaders;->hasBody(Lokhttp3/Response;)Z
  276. move-result v1
  277. if-nez v1, :cond_0
  278. const-wide/16 v1, 0x0
  279. invoke-virtual {p0, v1, v2}, Lokhttp3/internal/http1/Http1Codec;->newFixedLengthSource(J)Lokio/Source;
  280. move-result-object p1
  281. new-instance v3, Lokhttp3/internal/http/RealResponseBody;
  282. invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
  283. move-result-object p1
  284. invoke-direct {v3, v0, v1, v2, p1}, Lokhttp3/internal/http/RealResponseBody;-><init>(Ljava/lang/String;JLokio/BufferedSource;)V
  285. return-object v3
  286. :cond_0
  287. const-string v1, "Transfer-Encoding"
  288. invoke-virtual {p1, v1}, Lokhttp3/Response;->header(Ljava/lang/String;)Ljava/lang/String;
  289. move-result-object v1
  290. const-string v2, "chunked"
  291. invoke-virtual {v2, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  292. move-result v1
  293. const-wide/16 v2, -0x1
  294. if-eqz v1, :cond_1
  295. invoke-virtual {p1}, Lokhttp3/Response;->request()Lokhttp3/Request;
  296. move-result-object p1
  297. invoke-virtual {p1}, Lokhttp3/Request;->url()Lokhttp3/HttpUrl;
  298. move-result-object p1
  299. invoke-virtual {p0, p1}, Lokhttp3/internal/http1/Http1Codec;->newChunkedSource(Lokhttp3/HttpUrl;)Lokio/Source;
  300. move-result-object p1
  301. new-instance v1, Lokhttp3/internal/http/RealResponseBody;
  302. invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
  303. move-result-object p1
  304. invoke-direct {v1, v0, v2, v3, p1}, Lokhttp3/internal/http/RealResponseBody;-><init>(Ljava/lang/String;JLokio/BufferedSource;)V
  305. return-object v1
  306. :cond_1
  307. invoke-static {p1}, Lokhttp3/internal/http/HttpHeaders;->contentLength(Lokhttp3/Response;)J
  308. move-result-wide v4
  309. cmp-long p1, v4, v2
  310. if-eqz p1, :cond_2
  311. invoke-virtual {p0, v4, v5}, Lokhttp3/internal/http1/Http1Codec;->newFixedLengthSource(J)Lokio/Source;
  312. move-result-object p1
  313. new-instance v1, Lokhttp3/internal/http/RealResponseBody;
  314. invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
  315. move-result-object p1
  316. invoke-direct {v1, v0, v4, v5, p1}, Lokhttp3/internal/http/RealResponseBody;-><init>(Ljava/lang/String;JLokio/BufferedSource;)V
  317. return-object v1
  318. :cond_2
  319. new-instance p1, Lokhttp3/internal/http/RealResponseBody;
  320. invoke-virtual {p0}, Lokhttp3/internal/http1/Http1Codec;->newUnknownLengthSource()Lokio/Source;
  321. move-result-object v1
  322. invoke-static {v1}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
  323. move-result-object v1
  324. invoke-direct {p1, v0, v2, v3, v1}, Lokhttp3/internal/http/RealResponseBody;-><init>(Ljava/lang/String;JLokio/BufferedSource;)V
  325. return-object p1
  326. .end method
  327. .method public readHeaders()Lokhttp3/Headers;
  328. .locals 3
  329. .annotation system Ldalvik/annotation/Throws;
  330. value = {
  331. Ljava/io/IOException;
  332. }
  333. .end annotation
  334. new-instance v0, Lokhttp3/Headers$Builder;
  335. invoke-direct {v0}, Lokhttp3/Headers$Builder;-><init>()V
  336. :goto_0
  337. iget-object v1, p0, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/BufferedSource;
  338. invoke-interface {v1}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  339. move-result-object v1
  340. invoke-virtual {v1}, Ljava/lang/String;->length()I
  341. move-result v2
  342. if-eqz v2, :cond_0
  343. sget-object v2, Lokhttp3/internal/Internal;->instance:Lokhttp3/internal/Internal;
  344. invoke-virtual {v2, v0, v1}, Lokhttp3/internal/Internal;->addLenient(Lokhttp3/Headers$Builder;Ljava/lang/String;)V
  345. goto :goto_0
  346. :cond_0
  347. invoke-virtual {v0}, Lokhttp3/Headers$Builder;->build()Lokhttp3/Headers;
  348. move-result-object v0
  349. return-object v0
  350. .end method
  351. .method public readResponseHeaders(Z)Lokhttp3/Response$Builder;
  352. .locals 3
  353. .annotation system Ldalvik/annotation/Throws;
  354. value = {
  355. Ljava/io/IOException;
  356. }
  357. .end annotation
  358. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  359. const/4 v1, 0x1
  360. if-eq v0, v1, :cond_1
  361. const/4 v1, 0x3
  362. if-ne v0, v1, :cond_0
  363. goto :goto_0
  364. :cond_0
  365. new-instance p1, Ljava/lang/IllegalStateException;
  366. new-instance v0, Ljava/lang/StringBuilder;
  367. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  368. const-string v1, "state: "
  369. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  370. iget v1, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  371. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  372. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  373. move-result-object v0
  374. invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  375. throw p1
  376. :cond_1
  377. :goto_0
  378. :try_start_0
  379. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/BufferedSource;
  380. invoke-interface {v0}, Lokio/BufferedSource;->readUtf8LineStrict()Ljava/lang/String;
  381. move-result-object v0
  382. invoke-static {v0}, Lokhttp3/internal/http/StatusLine;->parse(Ljava/lang/String;)Lokhttp3/internal/http/StatusLine;
  383. move-result-object v0
  384. new-instance v1, Lokhttp3/Response$Builder;
  385. invoke-direct {v1}, Lokhttp3/Response$Builder;-><init>()V
  386. iget-object v2, v0, Lokhttp3/internal/http/StatusLine;->protocol:Lokhttp3/Protocol;
  387. invoke-virtual {v1, v2}, Lokhttp3/Response$Builder;->protocol(Lokhttp3/Protocol;)Lokhttp3/Response$Builder;
  388. move-result-object v1
  389. iget v2, v0, Lokhttp3/internal/http/StatusLine;->code:I
  390. invoke-virtual {v1, v2}, Lokhttp3/Response$Builder;->code(I)Lokhttp3/Response$Builder;
  391. move-result-object v1
  392. iget-object v2, v0, Lokhttp3/internal/http/StatusLine;->message:Ljava/lang/String;
  393. invoke-virtual {v1, v2}, Lokhttp3/Response$Builder;->message(Ljava/lang/String;)Lokhttp3/Response$Builder;
  394. move-result-object v1
  395. invoke-virtual {p0}, Lokhttp3/internal/http1/Http1Codec;->readHeaders()Lokhttp3/Headers;
  396. move-result-object v2
  397. invoke-virtual {v1, v2}, Lokhttp3/Response$Builder;->headers(Lokhttp3/Headers;)Lokhttp3/Response$Builder;
  398. move-result-object v1
  399. if-eqz p1, :cond_2
  400. iget p1, v0, Lokhttp3/internal/http/StatusLine;->code:I
  401. const/16 v0, 0x64
  402. if-ne p1, v0, :cond_2
  403. const/4 p1, 0x0
  404. return-object p1
  405. :cond_2
  406. const/4 p1, 0x4
  407. iput p1, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  408. :try_end_0
  409. .catch Ljava/io/EOFException; {:try_start_0 .. :try_end_0} :catch_0
  410. return-object v1
  411. :catch_0
  412. move-exception p1
  413. new-instance v0, Ljava/io/IOException;
  414. new-instance v1, Ljava/lang/StringBuilder;
  415. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  416. const-string v2, "unexpected end of stream on "
  417. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  418. iget-object v2, p0, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;
  419. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  420. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  421. move-result-object v1
  422. invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  423. invoke-virtual {v0, p1}, Ljava/io/IOException;->initCause(Ljava/lang/Throwable;)Ljava/lang/Throwable;
  424. throw v0
  425. .end method
  426. .method public writeRequest(Lokhttp3/Headers;Ljava/lang/String;)V
  427. .locals 4
  428. .annotation system Ldalvik/annotation/Throws;
  429. value = {
  430. Ljava/io/IOException;
  431. }
  432. .end annotation
  433. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  434. if-nez v0, :cond_1
  435. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  436. invoke-interface {v0, p2}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  437. move-result-object p2
  438. const-string v0, "\r\n"
  439. invoke-interface {p2, v0}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  440. const/4 p2, 0x0
  441. invoke-virtual {p1}, Lokhttp3/Headers;->size()I
  442. move-result v1
  443. :goto_0
  444. if-ge p2, v1, :cond_0
  445. iget-object v2, p0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  446. invoke-virtual {p1, p2}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
  447. move-result-object v3
  448. invoke-interface {v2, v3}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  449. move-result-object v2
  450. const-string v3, ": "
  451. invoke-interface {v2, v3}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  452. move-result-object v2
  453. invoke-virtual {p1, p2}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
  454. move-result-object v3
  455. invoke-interface {v2, v3}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  456. move-result-object v2
  457. invoke-interface {v2, v0}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  458. add-int/lit8 p2, p2, 0x1
  459. goto :goto_0
  460. :cond_0
  461. iget-object p1, p0, Lokhttp3/internal/http1/Http1Codec;->sink:Lokio/BufferedSink;
  462. invoke-interface {p1, v0}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  463. const/4 p1, 0x1
  464. iput p1, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  465. return-void
  466. :cond_1
  467. new-instance p1, Ljava/lang/IllegalStateException;
  468. new-instance p2, Ljava/lang/StringBuilder;
  469. invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
  470. const-string v0, "state: "
  471. invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  472. iget v0, p0, Lokhttp3/internal/http1/Http1Codec;->state:I
  473. invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  474. invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  475. move-result-object p2
  476. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  477. goto :goto_2
  478. :goto_1
  479. throw p1
  480. :goto_2
  481. goto :goto_1
  482. .end method
  483. .method public writeRequestHeaders(Lokhttp3/Request;)V
  484. .locals 1
  485. .annotation system Ldalvik/annotation/Throws;
  486. value = {
  487. Ljava/io/IOException;
  488. }
  489. .end annotation
  490. iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;
  491. invoke-virtual {v0}, Lokhttp3/internal/connection/StreamAllocation;->connection()Lokhttp3/internal/connection/RealConnection;
  492. move-result-object v0
  493. invoke-virtual {v0}, Lokhttp3/internal/connection/RealConnection;->route()Lokhttp3/Route;
  494. move-result-object v0
  495. invoke-virtual {v0}, Lokhttp3/Route;->proxy()Ljava/net/Proxy;
  496. move-result-object v0
  497. invoke-virtual {v0}, Ljava/net/Proxy;->type()Ljava/net/Proxy$Type;
  498. move-result-object v0
  499. invoke-static {p1, v0}, Lokhttp3/internal/http/RequestLine;->get(Lokhttp3/Request;Ljava/net/Proxy$Type;)Ljava/lang/String;
  500. move-result-object v0
  501. invoke-virtual {p1}, Lokhttp3/Request;->headers()Lokhttp3/Headers;
  502. move-result-object p1
  503. invoke-virtual {p0, p1, v0}, Lokhttp3/internal/http1/Http1Codec;->writeRequest(Lokhttp3/Headers;Ljava/lang/String;)V
  504. return-void
  505. .end method