MultipartBody.smali 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. .class public final Lokhttp3/MultipartBody;
  2. .super Lokhttp3/RequestBody;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/MemberClasses;
  6. value = {
  7. Lokhttp3/MultipartBody$Builder;,
  8. Lokhttp3/MultipartBody$Part;
  9. }
  10. .end annotation
  11. # static fields
  12. .field public static final ALTERNATIVE:Lokhttp3/MediaType;
  13. .field private static final COLONSPACE:[B
  14. .field private static final CRLF:[B
  15. .field private static final DASHDASH:[B
  16. .field public static final DIGEST:Lokhttp3/MediaType;
  17. .field public static final FORM:Lokhttp3/MediaType;
  18. .field public static final MIXED:Lokhttp3/MediaType;
  19. .field public static final PARALLEL:Lokhttp3/MediaType;
  20. # instance fields
  21. .field private final boundary:Lokio/ByteString;
  22. .field private contentLength:J
  23. .field private final contentType:Lokhttp3/MediaType;
  24. .field private final originalType:Lokhttp3/MediaType;
  25. .field private final parts:Ljava/util/List;
  26. .annotation system Ldalvik/annotation/Signature;
  27. value = {
  28. "Ljava/util/List<",
  29. "Lokhttp3/MultipartBody$Part;",
  30. ">;"
  31. }
  32. .end annotation
  33. .end field
  34. # direct methods
  35. .method static constructor <clinit>()V
  36. .locals 2
  37. const-string v0, "multipart/mixed"
  38. invoke-static {v0}, Lokhttp3/MediaType;->parse(Ljava/lang/String;)Lokhttp3/MediaType;
  39. move-result-object v0
  40. sput-object v0, Lokhttp3/MultipartBody;->MIXED:Lokhttp3/MediaType;
  41. const-string v0, "multipart/alternative"
  42. invoke-static {v0}, Lokhttp3/MediaType;->parse(Ljava/lang/String;)Lokhttp3/MediaType;
  43. move-result-object v0
  44. sput-object v0, Lokhttp3/MultipartBody;->ALTERNATIVE:Lokhttp3/MediaType;
  45. const-string v0, "multipart/digest"
  46. invoke-static {v0}, Lokhttp3/MediaType;->parse(Ljava/lang/String;)Lokhttp3/MediaType;
  47. move-result-object v0
  48. sput-object v0, Lokhttp3/MultipartBody;->DIGEST:Lokhttp3/MediaType;
  49. const-string v0, "multipart/parallel"
  50. invoke-static {v0}, Lokhttp3/MediaType;->parse(Ljava/lang/String;)Lokhttp3/MediaType;
  51. move-result-object v0
  52. sput-object v0, Lokhttp3/MultipartBody;->PARALLEL:Lokhttp3/MediaType;
  53. const-string v0, "multipart/form-data"
  54. invoke-static {v0}, Lokhttp3/MediaType;->parse(Ljava/lang/String;)Lokhttp3/MediaType;
  55. move-result-object v0
  56. sput-object v0, Lokhttp3/MultipartBody;->FORM:Lokhttp3/MediaType;
  57. const/4 v0, 0x2
  58. new-array v1, v0, [B
  59. fill-array-data v1, :array_0
  60. sput-object v1, Lokhttp3/MultipartBody;->COLONSPACE:[B
  61. new-array v1, v0, [B
  62. fill-array-data v1, :array_1
  63. sput-object v1, Lokhttp3/MultipartBody;->CRLF:[B
  64. new-array v0, v0, [B
  65. fill-array-data v0, :array_2
  66. sput-object v0, Lokhttp3/MultipartBody;->DASHDASH:[B
  67. return-void
  68. nop
  69. :array_0
  70. .array-data 1
  71. 0x3at
  72. 0x20t
  73. .end array-data
  74. nop
  75. :array_1
  76. .array-data 1
  77. 0xdt
  78. 0xat
  79. .end array-data
  80. nop
  81. :array_2
  82. .array-data 1
  83. 0x2dt
  84. 0x2dt
  85. .end array-data
  86. .end method
  87. .method constructor <init>(Lokio/ByteString;Lokhttp3/MediaType;Ljava/util/List;)V
  88. .locals 2
  89. .annotation system Ldalvik/annotation/Signature;
  90. value = {
  91. "(",
  92. "Lokio/ByteString;",
  93. "Lokhttp3/MediaType;",
  94. "Ljava/util/List<",
  95. "Lokhttp3/MultipartBody$Part;",
  96. ">;)V"
  97. }
  98. .end annotation
  99. invoke-direct {p0}, Lokhttp3/RequestBody;-><init>()V
  100. const-wide/16 v0, -0x1
  101. iput-wide v0, p0, Lokhttp3/MultipartBody;->contentLength:J
  102. iput-object p1, p0, Lokhttp3/MultipartBody;->boundary:Lokio/ByteString;
  103. iput-object p2, p0, Lokhttp3/MultipartBody;->originalType:Lokhttp3/MediaType;
  104. new-instance v0, Ljava/lang/StringBuilder;
  105. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  106. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  107. const-string p2, "; boundary="
  108. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  109. invoke-virtual {p1}, Lokio/ByteString;->utf8()Ljava/lang/String;
  110. move-result-object p1
  111. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  112. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  113. move-result-object p1
  114. invoke-static {p1}, Lokhttp3/MediaType;->parse(Ljava/lang/String;)Lokhttp3/MediaType;
  115. move-result-object p1
  116. iput-object p1, p0, Lokhttp3/MultipartBody;->contentType:Lokhttp3/MediaType;
  117. invoke-static {p3}, Lokhttp3/internal/Util;->immutableList(Ljava/util/List;)Ljava/util/List;
  118. move-result-object p1
  119. iput-object p1, p0, Lokhttp3/MultipartBody;->parts:Ljava/util/List;
  120. return-void
  121. .end method
  122. .method static appendQuotedString(Ljava/lang/StringBuilder;Ljava/lang/String;)Ljava/lang/StringBuilder;
  123. .locals 5
  124. const/16 v0, 0x22
  125. invoke-virtual {p0, v0}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
  126. invoke-virtual {p1}, Ljava/lang/String;->length()I
  127. move-result v1
  128. const/4 v2, 0x0
  129. :goto_0
  130. if-ge v2, v1, :cond_3
  131. invoke-virtual {p1, v2}, Ljava/lang/String;->charAt(I)C
  132. move-result v3
  133. const/16 v4, 0xa
  134. if-eq v3, v4, :cond_2
  135. const/16 v4, 0xd
  136. if-eq v3, v4, :cond_1
  137. if-eq v3, v0, :cond_0
  138. invoke-virtual {p0, v3}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
  139. goto :goto_2
  140. :cond_0
  141. const-string v3, "%22"
  142. goto :goto_1
  143. :cond_1
  144. const-string v3, "%0D"
  145. goto :goto_1
  146. :cond_2
  147. const-string v3, "%0A"
  148. :goto_1
  149. invoke-virtual {p0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  150. :goto_2
  151. add-int/lit8 v2, v2, 0x1
  152. goto :goto_0
  153. :cond_3
  154. invoke-virtual {p0, v0}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
  155. return-object p0
  156. .end method
  157. .method private writeOrCountBytes(Lokio/BufferedSink;Z)J
  158. .locals 12
  159. .annotation system Ldalvik/annotation/Throws;
  160. value = {
  161. Ljava/io/IOException;
  162. }
  163. .end annotation
  164. if-eqz p2, :cond_0
  165. new-instance p1, Lokio/Buffer;
  166. invoke-direct {p1}, Lokio/Buffer;-><init>()V
  167. move-object v0, p1
  168. goto :goto_0
  169. :cond_0
  170. const/4 v0, 0x0
  171. :goto_0
  172. iget-object v1, p0, Lokhttp3/MultipartBody;->parts:Ljava/util/List;
  173. invoke-interface {v1}, Ljava/util/List;->size()I
  174. move-result v1
  175. const/4 v2, 0x0
  176. const-wide/16 v3, 0x0
  177. move-wide v4, v3
  178. const/4 v3, 0x0
  179. :goto_1
  180. if-ge v3, v1, :cond_6
  181. iget-object v6, p0, Lokhttp3/MultipartBody;->parts:Ljava/util/List;
  182. invoke-interface {v6, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;
  183. move-result-object v6
  184. check-cast v6, Lokhttp3/MultipartBody$Part;
  185. iget-object v7, v6, Lokhttp3/MultipartBody$Part;->headers:Lokhttp3/Headers;
  186. iget-object v6, v6, Lokhttp3/MultipartBody$Part;->body:Lokhttp3/RequestBody;
  187. sget-object v8, Lokhttp3/MultipartBody;->DASHDASH:[B
  188. invoke-interface {p1, v8}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  189. iget-object v8, p0, Lokhttp3/MultipartBody;->boundary:Lokio/ByteString;
  190. invoke-interface {p1, v8}, Lokio/BufferedSink;->write(Lokio/ByteString;)Lokio/BufferedSink;
  191. sget-object v8, Lokhttp3/MultipartBody;->CRLF:[B
  192. invoke-interface {p1, v8}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  193. if-eqz v7, :cond_1
  194. invoke-virtual {v7}, Lokhttp3/Headers;->size()I
  195. move-result v8
  196. const/4 v9, 0x0
  197. :goto_2
  198. if-ge v9, v8, :cond_1
  199. invoke-virtual {v7, v9}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
  200. move-result-object v10
  201. invoke-interface {p1, v10}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  202. move-result-object v10
  203. sget-object v11, Lokhttp3/MultipartBody;->COLONSPACE:[B
  204. invoke-interface {v10, v11}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  205. move-result-object v10
  206. invoke-virtual {v7, v9}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
  207. move-result-object v11
  208. invoke-interface {v10, v11}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  209. move-result-object v10
  210. sget-object v11, Lokhttp3/MultipartBody;->CRLF:[B
  211. invoke-interface {v10, v11}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  212. add-int/lit8 v9, v9, 0x1
  213. goto :goto_2
  214. :cond_1
  215. invoke-virtual {v6}, Lokhttp3/RequestBody;->contentType()Lokhttp3/MediaType;
  216. move-result-object v7
  217. if-eqz v7, :cond_2
  218. const-string v8, "Content-Type: "
  219. invoke-interface {p1, v8}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  220. move-result-object v8
  221. invoke-virtual {v7}, Lokhttp3/MediaType;->toString()Ljava/lang/String;
  222. move-result-object v7
  223. invoke-interface {v8, v7}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  224. move-result-object v7
  225. sget-object v8, Lokhttp3/MultipartBody;->CRLF:[B
  226. invoke-interface {v7, v8}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  227. :cond_2
  228. invoke-virtual {v6}, Lokhttp3/RequestBody;->contentLength()J
  229. move-result-wide v7
  230. const-wide/16 v9, -0x1
  231. cmp-long v11, v7, v9
  232. if-eqz v11, :cond_3
  233. const-string v9, "Content-Length: "
  234. invoke-interface {p1, v9}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
  235. move-result-object v9
  236. invoke-interface {v9, v7, v8}, Lokio/BufferedSink;->writeDecimalLong(J)Lokio/BufferedSink;
  237. move-result-object v9
  238. sget-object v10, Lokhttp3/MultipartBody;->CRLF:[B
  239. invoke-interface {v9, v10}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  240. goto :goto_3
  241. :cond_3
  242. if-eqz p2, :cond_4
  243. invoke-virtual {v0}, Lokio/Buffer;->clear()V
  244. return-wide v9
  245. :cond_4
  246. :goto_3
  247. sget-object v9, Lokhttp3/MultipartBody;->CRLF:[B
  248. invoke-interface {p1, v9}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  249. if-eqz p2, :cond_5
  250. add-long/2addr v4, v7
  251. goto :goto_4
  252. :cond_5
  253. invoke-virtual {v6, p1}, Lokhttp3/RequestBody;->writeTo(Lokio/BufferedSink;)V
  254. :goto_4
  255. sget-object v6, Lokhttp3/MultipartBody;->CRLF:[B
  256. invoke-interface {p1, v6}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  257. add-int/lit8 v3, v3, 0x1
  258. goto/16 :goto_1
  259. :cond_6
  260. sget-object v1, Lokhttp3/MultipartBody;->DASHDASH:[B
  261. invoke-interface {p1, v1}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  262. iget-object v1, p0, Lokhttp3/MultipartBody;->boundary:Lokio/ByteString;
  263. invoke-interface {p1, v1}, Lokio/BufferedSink;->write(Lokio/ByteString;)Lokio/BufferedSink;
  264. sget-object v1, Lokhttp3/MultipartBody;->DASHDASH:[B
  265. invoke-interface {p1, v1}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  266. sget-object v1, Lokhttp3/MultipartBody;->CRLF:[B
  267. invoke-interface {p1, v1}, Lokio/BufferedSink;->write([B)Lokio/BufferedSink;
  268. if-eqz p2, :cond_7
  269. invoke-virtual {v0}, Lokio/Buffer;->size()J
  270. move-result-wide p1
  271. add-long/2addr v4, p1
  272. invoke-virtual {v0}, Lokio/Buffer;->clear()V
  273. :cond_7
  274. return-wide v4
  275. .end method
  276. # virtual methods
  277. .method public boundary()Ljava/lang/String;
  278. .locals 1
  279. iget-object v0, p0, Lokhttp3/MultipartBody;->boundary:Lokio/ByteString;
  280. invoke-virtual {v0}, Lokio/ByteString;->utf8()Ljava/lang/String;
  281. move-result-object v0
  282. return-object v0
  283. .end method
  284. .method public contentLength()J
  285. .locals 5
  286. .annotation system Ldalvik/annotation/Throws;
  287. value = {
  288. Ljava/io/IOException;
  289. }
  290. .end annotation
  291. iget-wide v0, p0, Lokhttp3/MultipartBody;->contentLength:J
  292. const-wide/16 v2, -0x1
  293. cmp-long v4, v0, v2
  294. if-eqz v4, :cond_0
  295. return-wide v0
  296. :cond_0
  297. const/4 v0, 0x0
  298. const/4 v1, 0x1
  299. invoke-direct {p0, v0, v1}, Lokhttp3/MultipartBody;->writeOrCountBytes(Lokio/BufferedSink;Z)J
  300. move-result-wide v0
  301. iput-wide v0, p0, Lokhttp3/MultipartBody;->contentLength:J
  302. return-wide v0
  303. .end method
  304. .method public contentType()Lokhttp3/MediaType;
  305. .locals 1
  306. iget-object v0, p0, Lokhttp3/MultipartBody;->contentType:Lokhttp3/MediaType;
  307. return-object v0
  308. .end method
  309. .method public part(I)Lokhttp3/MultipartBody$Part;
  310. .locals 1
  311. iget-object v0, p0, Lokhttp3/MultipartBody;->parts:Ljava/util/List;
  312. invoke-interface {v0, p1}, Ljava/util/List;->get(I)Ljava/lang/Object;
  313. move-result-object p1
  314. check-cast p1, Lokhttp3/MultipartBody$Part;
  315. return-object p1
  316. .end method
  317. .method public parts()Ljava/util/List;
  318. .locals 1
  319. .annotation system Ldalvik/annotation/Signature;
  320. value = {
  321. "()",
  322. "Ljava/util/List<",
  323. "Lokhttp3/MultipartBody$Part;",
  324. ">;"
  325. }
  326. .end annotation
  327. iget-object v0, p0, Lokhttp3/MultipartBody;->parts:Ljava/util/List;
  328. return-object v0
  329. .end method
  330. .method public size()I
  331. .locals 1
  332. iget-object v0, p0, Lokhttp3/MultipartBody;->parts:Ljava/util/List;
  333. invoke-interface {v0}, Ljava/util/List;->size()I
  334. move-result v0
  335. return v0
  336. .end method
  337. .method public type()Lokhttp3/MediaType;
  338. .locals 1
  339. iget-object v0, p0, Lokhttp3/MultipartBody;->originalType:Lokhttp3/MediaType;
  340. return-object v0
  341. .end method
  342. .method public writeTo(Lokio/BufferedSink;)V
  343. .locals 1
  344. .annotation system Ldalvik/annotation/Throws;
  345. value = {
  346. Ljava/io/IOException;
  347. }
  348. .end annotation
  349. const/4 v0, 0x0
  350. invoke-direct {p0, p1, v0}, Lokhttp3/MultipartBody;->writeOrCountBytes(Lokio/BufferedSink;Z)J
  351. return-void
  352. .end method