Request$Builder.smali 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. .class public Lokhttp3/Request$Builder;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/Request;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x9
  10. name = "Builder"
  11. .end annotation
  12. # instance fields
  13. .field body:Lokhttp3/RequestBody;
  14. .field headers:Lokhttp3/Headers$Builder;
  15. .field method:Ljava/lang/String;
  16. .field tag:Ljava/lang/Object;
  17. .field url:Lokhttp3/HttpUrl;
  18. # direct methods
  19. .method public constructor <init>()V
  20. .locals 1
  21. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  22. const-string v0, "GET"
  23. iput-object v0, p0, Lokhttp3/Request$Builder;->method:Ljava/lang/String;
  24. new-instance v0, Lokhttp3/Headers$Builder;
  25. invoke-direct {v0}, Lokhttp3/Headers$Builder;-><init>()V
  26. iput-object v0, p0, Lokhttp3/Request$Builder;->headers:Lokhttp3/Headers$Builder;
  27. return-void
  28. .end method
  29. .method constructor <init>(Lokhttp3/Request;)V
  30. .locals 1
  31. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  32. iget-object v0, p1, Lokhttp3/Request;->url:Lokhttp3/HttpUrl;
  33. iput-object v0, p0, Lokhttp3/Request$Builder;->url:Lokhttp3/HttpUrl;
  34. iget-object v0, p1, Lokhttp3/Request;->method:Ljava/lang/String;
  35. iput-object v0, p0, Lokhttp3/Request$Builder;->method:Ljava/lang/String;
  36. iget-object v0, p1, Lokhttp3/Request;->body:Lokhttp3/RequestBody;
  37. iput-object v0, p0, Lokhttp3/Request$Builder;->body:Lokhttp3/RequestBody;
  38. iget-object v0, p1, Lokhttp3/Request;->tag:Ljava/lang/Object;
  39. iput-object v0, p0, Lokhttp3/Request$Builder;->tag:Ljava/lang/Object;
  40. iget-object p1, p1, Lokhttp3/Request;->headers:Lokhttp3/Headers;
  41. invoke-virtual {p1}, Lokhttp3/Headers;->newBuilder()Lokhttp3/Headers$Builder;
  42. move-result-object p1
  43. iput-object p1, p0, Lokhttp3/Request$Builder;->headers:Lokhttp3/Headers$Builder;
  44. return-void
  45. .end method
  46. # virtual methods
  47. .method public addHeader(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Request$Builder;
  48. .locals 1
  49. iget-object v0, p0, Lokhttp3/Request$Builder;->headers:Lokhttp3/Headers$Builder;
  50. invoke-virtual {v0, p1, p2}, Lokhttp3/Headers$Builder;->add(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  51. return-object p0
  52. .end method
  53. .method public build()Lokhttp3/Request;
  54. .locals 2
  55. iget-object v0, p0, Lokhttp3/Request$Builder;->url:Lokhttp3/HttpUrl;
  56. if-eqz v0, :cond_0
  57. new-instance v0, Lokhttp3/Request;
  58. invoke-direct {v0, p0}, Lokhttp3/Request;-><init>(Lokhttp3/Request$Builder;)V
  59. return-object v0
  60. :cond_0
  61. new-instance v0, Ljava/lang/IllegalStateException;
  62. const-string v1, "url == null"
  63. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  64. throw v0
  65. .end method
  66. .method public cacheControl(Lokhttp3/CacheControl;)Lokhttp3/Request$Builder;
  67. .locals 2
  68. invoke-virtual {p1}, Lokhttp3/CacheControl;->toString()Ljava/lang/String;
  69. move-result-object p1
  70. invoke-virtual {p1}, Ljava/lang/String;->isEmpty()Z
  71. move-result v0
  72. const-string v1, "Cache-Control"
  73. if-eqz v0, :cond_0
  74. invoke-virtual {p0, v1}, Lokhttp3/Request$Builder;->removeHeader(Ljava/lang/String;)Lokhttp3/Request$Builder;
  75. move-result-object p1
  76. return-object p1
  77. :cond_0
  78. invoke-virtual {p0, v1, p1}, Lokhttp3/Request$Builder;->header(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Request$Builder;
  79. move-result-object p1
  80. return-object p1
  81. .end method
  82. .method public delete()Lokhttp3/Request$Builder;
  83. .locals 1
  84. sget-object v0, Lokhttp3/internal/Util;->EMPTY_REQUEST:Lokhttp3/RequestBody;
  85. invoke-virtual {p0, v0}, Lokhttp3/Request$Builder;->delete(Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  86. move-result-object v0
  87. return-object v0
  88. .end method
  89. .method public delete(Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  90. .locals 1
  91. const-string v0, "DELETE"
  92. invoke-virtual {p0, v0, p1}, Lokhttp3/Request$Builder;->method(Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  93. move-result-object p1
  94. return-object p1
  95. .end method
  96. .method public get()Lokhttp3/Request$Builder;
  97. .locals 2
  98. const-string v0, "GET"
  99. const/4 v1, 0x0
  100. invoke-virtual {p0, v0, v1}, Lokhttp3/Request$Builder;->method(Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  101. move-result-object v0
  102. return-object v0
  103. .end method
  104. .method public head()Lokhttp3/Request$Builder;
  105. .locals 2
  106. const-string v0, "HEAD"
  107. const/4 v1, 0x0
  108. invoke-virtual {p0, v0, v1}, Lokhttp3/Request$Builder;->method(Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  109. move-result-object v0
  110. return-object v0
  111. .end method
  112. .method public header(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Request$Builder;
  113. .locals 1
  114. iget-object v0, p0, Lokhttp3/Request$Builder;->headers:Lokhttp3/Headers$Builder;
  115. invoke-virtual {v0, p1, p2}, Lokhttp3/Headers$Builder;->set(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  116. return-object p0
  117. .end method
  118. .method public headers(Lokhttp3/Headers;)Lokhttp3/Request$Builder;
  119. .locals 0
  120. invoke-virtual {p1}, Lokhttp3/Headers;->newBuilder()Lokhttp3/Headers$Builder;
  121. move-result-object p1
  122. iput-object p1, p0, Lokhttp3/Request$Builder;->headers:Lokhttp3/Headers$Builder;
  123. return-object p0
  124. .end method
  125. .method public method(Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  126. .locals 2
  127. if-eqz p1, :cond_5
  128. invoke-virtual {p1}, Ljava/lang/String;->length()I
  129. move-result v0
  130. if-eqz v0, :cond_4
  131. const-string v0, "method "
  132. if-eqz p2, :cond_1
  133. invoke-static {p1}, Lokhttp3/internal/http/HttpMethod;->permitsRequestBody(Ljava/lang/String;)Z
  134. move-result v1
  135. if-eqz v1, :cond_0
  136. goto :goto_0
  137. :cond_0
  138. new-instance p2, Ljava/lang/IllegalArgumentException;
  139. new-instance v1, Ljava/lang/StringBuilder;
  140. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  141. invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  142. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  143. const-string p1, " must not have a request body."
  144. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  145. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  146. move-result-object p1
  147. invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  148. throw p2
  149. :cond_1
  150. :goto_0
  151. if-nez p2, :cond_3
  152. invoke-static {p1}, Lokhttp3/internal/http/HttpMethod;->requiresRequestBody(Ljava/lang/String;)Z
  153. move-result v1
  154. if-nez v1, :cond_2
  155. goto :goto_1
  156. :cond_2
  157. new-instance p2, Ljava/lang/IllegalArgumentException;
  158. new-instance v1, Ljava/lang/StringBuilder;
  159. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  160. invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  161. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  162. const-string p1, " must have a request body."
  163. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  164. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  165. move-result-object p1
  166. invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  167. throw p2
  168. :cond_3
  169. :goto_1
  170. iput-object p1, p0, Lokhttp3/Request$Builder;->method:Ljava/lang/String;
  171. iput-object p2, p0, Lokhttp3/Request$Builder;->body:Lokhttp3/RequestBody;
  172. return-object p0
  173. :cond_4
  174. new-instance p1, Ljava/lang/IllegalArgumentException;
  175. const-string p2, "method.length() == 0"
  176. invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  177. throw p1
  178. :cond_5
  179. new-instance p1, Ljava/lang/NullPointerException;
  180. const-string p2, "method == null"
  181. invoke-direct {p1, p2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  182. throw p1
  183. .end method
  184. .method public patch(Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  185. .locals 1
  186. const-string v0, "PATCH"
  187. invoke-virtual {p0, v0, p1}, Lokhttp3/Request$Builder;->method(Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  188. move-result-object p1
  189. return-object p1
  190. .end method
  191. .method public post(Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  192. .locals 1
  193. const-string v0, "POST"
  194. invoke-virtual {p0, v0, p1}, Lokhttp3/Request$Builder;->method(Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  195. move-result-object p1
  196. return-object p1
  197. .end method
  198. .method public put(Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  199. .locals 1
  200. const-string v0, "PUT"
  201. invoke-virtual {p0, v0, p1}, Lokhttp3/Request$Builder;->method(Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/Request$Builder;
  202. move-result-object p1
  203. return-object p1
  204. .end method
  205. .method public removeHeader(Ljava/lang/String;)Lokhttp3/Request$Builder;
  206. .locals 1
  207. iget-object v0, p0, Lokhttp3/Request$Builder;->headers:Lokhttp3/Headers$Builder;
  208. invoke-virtual {v0, p1}, Lokhttp3/Headers$Builder;->removeAll(Ljava/lang/String;)Lokhttp3/Headers$Builder;
  209. return-object p0
  210. .end method
  211. .method public tag(Ljava/lang/Object;)Lokhttp3/Request$Builder;
  212. .locals 0
  213. iput-object p1, p0, Lokhttp3/Request$Builder;->tag:Ljava/lang/Object;
  214. return-object p0
  215. .end method
  216. .method public url(Ljava/lang/String;)Lokhttp3/Request$Builder;
  217. .locals 6
  218. if-eqz p1, :cond_3
  219. const/4 v1, 0x1
  220. const/4 v2, 0x0
  221. const/4 v4, 0x0
  222. const/4 v5, 0x3
  223. const-string v3, "ws:"
  224. move-object v0, p1
  225. invoke-virtual/range {v0 .. v5}, Ljava/lang/String;->regionMatches(ZILjava/lang/String;II)Z
  226. move-result v0
  227. if-eqz v0, :cond_0
  228. new-instance v0, Ljava/lang/StringBuilder;
  229. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  230. const-string v1, "http:"
  231. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  232. const/4 v1, 0x3
  233. :goto_0
  234. invoke-virtual {p1, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  235. move-result-object p1
  236. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  237. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  238. move-result-object p1
  239. goto :goto_1
  240. :cond_0
  241. const/4 v1, 0x1
  242. const/4 v2, 0x0
  243. const/4 v4, 0x0
  244. const/4 v5, 0x4
  245. const-string v3, "wss:"
  246. move-object v0, p1
  247. invoke-virtual/range {v0 .. v5}, Ljava/lang/String;->regionMatches(ZILjava/lang/String;II)Z
  248. move-result v0
  249. if-eqz v0, :cond_1
  250. new-instance v0, Ljava/lang/StringBuilder;
  251. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  252. const-string v1, "https:"
  253. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  254. const/4 v1, 0x4
  255. goto :goto_0
  256. :cond_1
  257. :goto_1
  258. invoke-static {p1}, Lokhttp3/HttpUrl;->parse(Ljava/lang/String;)Lokhttp3/HttpUrl;
  259. move-result-object v0
  260. if-eqz v0, :cond_2
  261. invoke-virtual {p0, v0}, Lokhttp3/Request$Builder;->url(Lokhttp3/HttpUrl;)Lokhttp3/Request$Builder;
  262. move-result-object p1
  263. return-object p1
  264. :cond_2
  265. new-instance v0, Ljava/lang/IllegalArgumentException;
  266. new-instance v1, Ljava/lang/StringBuilder;
  267. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  268. const-string v2, "unexpected url: "
  269. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  270. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  271. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  272. move-result-object p1
  273. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  274. throw v0
  275. :cond_3
  276. new-instance p1, Ljava/lang/NullPointerException;
  277. const-string v0, "url == null"
  278. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  279. goto :goto_3
  280. :goto_2
  281. throw p1
  282. :goto_3
  283. goto :goto_2
  284. .end method
  285. .method public url(Ljava/net/URL;)Lokhttp3/Request$Builder;
  286. .locals 3
  287. if-eqz p1, :cond_1
  288. invoke-static {p1}, Lokhttp3/HttpUrl;->get(Ljava/net/URL;)Lokhttp3/HttpUrl;
  289. move-result-object v0
  290. if-eqz v0, :cond_0
  291. invoke-virtual {p0, v0}, Lokhttp3/Request$Builder;->url(Lokhttp3/HttpUrl;)Lokhttp3/Request$Builder;
  292. move-result-object p1
  293. return-object p1
  294. :cond_0
  295. new-instance v0, Ljava/lang/IllegalArgumentException;
  296. new-instance v1, Ljava/lang/StringBuilder;
  297. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  298. const-string v2, "unexpected url: "
  299. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  300. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  301. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  302. move-result-object p1
  303. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  304. throw v0
  305. :cond_1
  306. new-instance p1, Ljava/lang/NullPointerException;
  307. const-string v0, "url == null"
  308. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  309. throw p1
  310. .end method
  311. .method public url(Lokhttp3/HttpUrl;)Lokhttp3/Request$Builder;
  312. .locals 1
  313. if-eqz p1, :cond_0
  314. iput-object p1, p0, Lokhttp3/Request$Builder;->url:Lokhttp3/HttpUrl;
  315. return-object p0
  316. :cond_0
  317. new-instance p1, Ljava/lang/NullPointerException;
  318. const-string v0, "url == null"
  319. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  320. throw p1
  321. .end method