MultipartBody$Part.smali 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. .class public final Lokhttp3/MultipartBody$Part;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/MultipartBody;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x19
  10. name = "Part"
  11. .end annotation
  12. # instance fields
  13. .field final body:Lokhttp3/RequestBody;
  14. .field final headers:Lokhttp3/Headers;
  15. # direct methods
  16. .method private constructor <init>(Lokhttp3/Headers;Lokhttp3/RequestBody;)V
  17. .locals 0
  18. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  19. iput-object p1, p0, Lokhttp3/MultipartBody$Part;->headers:Lokhttp3/Headers;
  20. iput-object p2, p0, Lokhttp3/MultipartBody$Part;->body:Lokhttp3/RequestBody;
  21. return-void
  22. .end method
  23. .method public static create(Lokhttp3/Headers;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  24. .locals 1
  25. if-eqz p1, :cond_4
  26. if-eqz p0, :cond_1
  27. const-string v0, "Content-Type"
  28. invoke-virtual {p0, v0}, Lokhttp3/Headers;->get(Ljava/lang/String;)Ljava/lang/String;
  29. move-result-object v0
  30. if-nez v0, :cond_0
  31. goto :goto_0
  32. :cond_0
  33. new-instance p0, Ljava/lang/IllegalArgumentException;
  34. const-string p1, "Unexpected header: Content-Type"
  35. invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  36. throw p0
  37. :cond_1
  38. :goto_0
  39. if-eqz p0, :cond_3
  40. const-string v0, "Content-Length"
  41. invoke-virtual {p0, v0}, Lokhttp3/Headers;->get(Ljava/lang/String;)Ljava/lang/String;
  42. move-result-object v0
  43. if-nez v0, :cond_2
  44. goto :goto_1
  45. :cond_2
  46. new-instance p0, Ljava/lang/IllegalArgumentException;
  47. const-string p1, "Unexpected header: Content-Length"
  48. invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  49. throw p0
  50. :cond_3
  51. :goto_1
  52. new-instance v0, Lokhttp3/MultipartBody$Part;
  53. invoke-direct {v0, p0, p1}, Lokhttp3/MultipartBody$Part;-><init>(Lokhttp3/Headers;Lokhttp3/RequestBody;)V
  54. return-object v0
  55. :cond_4
  56. new-instance p0, Ljava/lang/NullPointerException;
  57. const-string p1, "body == null"
  58. invoke-direct {p0, p1}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  59. throw p0
  60. .end method
  61. .method public static create(Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  62. .locals 1
  63. const/4 v0, 0x0
  64. invoke-static {v0, p0}, Lokhttp3/MultipartBody$Part;->create(Lokhttp3/Headers;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  65. move-result-object p0
  66. return-object p0
  67. .end method
  68. .method public static createFormData(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/MultipartBody$Part;
  69. .locals 1
  70. const/4 v0, 0x0
  71. invoke-static {v0, p1}, Lokhttp3/RequestBody;->create(Lokhttp3/MediaType;Ljava/lang/String;)Lokhttp3/RequestBody;
  72. move-result-object p1
  73. invoke-static {p0, v0, p1}, Lokhttp3/MultipartBody$Part;->createFormData(Ljava/lang/String;Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  74. move-result-object p0
  75. return-object p0
  76. .end method
  77. .method public static createFormData(Ljava/lang/String;Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  78. .locals 2
  79. if-eqz p0, :cond_1
  80. new-instance v0, Ljava/lang/StringBuilder;
  81. const-string v1, "form-data; name="
  82. invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
  83. invoke-static {v0, p0}, Lokhttp3/MultipartBody;->appendQuotedString(Ljava/lang/StringBuilder;Ljava/lang/String;)Ljava/lang/StringBuilder;
  84. if-eqz p1, :cond_0
  85. const-string p0, "; filename="
  86. invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  87. invoke-static {v0, p1}, Lokhttp3/MultipartBody;->appendQuotedString(Ljava/lang/StringBuilder;Ljava/lang/String;)Ljava/lang/StringBuilder;
  88. :cond_0
  89. const/4 p0, 0x2
  90. new-array p0, p0, [Ljava/lang/String;
  91. const/4 p1, 0x0
  92. const-string v1, "Content-Disposition"
  93. aput-object v1, p0, p1
  94. const/4 p1, 0x1
  95. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  96. move-result-object v0
  97. aput-object v0, p0, p1
  98. invoke-static {p0}, Lokhttp3/Headers;->of([Ljava/lang/String;)Lokhttp3/Headers;
  99. move-result-object p0
  100. invoke-static {p0, p2}, Lokhttp3/MultipartBody$Part;->create(Lokhttp3/Headers;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  101. move-result-object p0
  102. return-object p0
  103. :cond_1
  104. new-instance p0, Ljava/lang/NullPointerException;
  105. const-string p1, "name == null"
  106. invoke-direct {p0, p1}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  107. throw p0
  108. .end method
  109. # virtual methods
  110. .method public body()Lokhttp3/RequestBody;
  111. .locals 1
  112. iget-object v0, p0, Lokhttp3/MultipartBody$Part;->body:Lokhttp3/RequestBody;
  113. return-object v0
  114. .end method
  115. .method public headers()Lokhttp3/Headers;
  116. .locals 1
  117. iget-object v0, p0, Lokhttp3/MultipartBody$Part;->headers:Lokhttp3/Headers;
  118. return-object v0
  119. .end method