StatusLine.smali 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. .class public final Lokhttp3/internal/http/StatusLine;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # static fields
  5. .field public static final HTTP_CONTINUE:I = 0x64
  6. .field public static final HTTP_PERM_REDIRECT:I = 0x134
  7. .field public static final HTTP_TEMP_REDIRECT:I = 0x133
  8. # instance fields
  9. .field public final code:I
  10. .field public final message:Ljava/lang/String;
  11. .field public final protocol:Lokhttp3/Protocol;
  12. # direct methods
  13. .method public constructor <init>(Lokhttp3/Protocol;ILjava/lang/String;)V
  14. .locals 0
  15. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  16. iput-object p1, p0, Lokhttp3/internal/http/StatusLine;->protocol:Lokhttp3/Protocol;
  17. iput p2, p0, Lokhttp3/internal/http/StatusLine;->code:I
  18. iput-object p3, p0, Lokhttp3/internal/http/StatusLine;->message:Ljava/lang/String;
  19. return-void
  20. .end method
  21. .method public static get(Lokhttp3/Response;)Lokhttp3/internal/http/StatusLine;
  22. .locals 3
  23. new-instance v0, Lokhttp3/internal/http/StatusLine;
  24. invoke-virtual {p0}, Lokhttp3/Response;->protocol()Lokhttp3/Protocol;
  25. move-result-object v1
  26. invoke-virtual {p0}, Lokhttp3/Response;->code()I
  27. move-result v2
  28. invoke-virtual {p0}, Lokhttp3/Response;->message()Ljava/lang/String;
  29. move-result-object p0
  30. invoke-direct {v0, v1, v2, p0}, Lokhttp3/internal/http/StatusLine;-><init>(Lokhttp3/Protocol;ILjava/lang/String;)V
  31. return-object v0
  32. .end method
  33. .method public static parse(Ljava/lang/String;)Lokhttp3/internal/http/StatusLine;
  34. .locals 8
  35. .annotation system Ldalvik/annotation/Throws;
  36. value = {
  37. Ljava/io/IOException;
  38. }
  39. .end annotation
  40. const-string v0, "HTTP/1."
  41. invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  42. move-result v0
  43. const/16 v1, 0x20
  44. const/4 v2, 0x4
  45. const/16 v3, 0x9
  46. const-string v4, "Unexpected status line: "
  47. if-eqz v0, :cond_3
  48. invoke-virtual {p0}, Ljava/lang/String;->length()I
  49. move-result v0
  50. if-lt v0, v3, :cond_2
  51. const/16 v0, 0x8
  52. invoke-virtual {p0, v0}, Ljava/lang/String;->charAt(I)C
  53. move-result v0
  54. if-ne v0, v1, :cond_2
  55. const/4 v0, 0x7
  56. invoke-virtual {p0, v0}, Ljava/lang/String;->charAt(I)C
  57. move-result v0
  58. add-int/lit8 v0, v0, -0x30
  59. if-nez v0, :cond_0
  60. sget-object v0, Lokhttp3/Protocol;->HTTP_1_0:Lokhttp3/Protocol;
  61. goto :goto_0
  62. :cond_0
  63. const/4 v5, 0x1
  64. if-ne v0, v5, :cond_1
  65. sget-object v0, Lokhttp3/Protocol;->HTTP_1_1:Lokhttp3/Protocol;
  66. goto :goto_0
  67. :cond_1
  68. new-instance v0, Ljava/net/ProtocolException;
  69. new-instance v1, Ljava/lang/StringBuilder;
  70. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  71. invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  72. invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  73. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  74. move-result-object p0
  75. invoke-direct {v0, p0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  76. throw v0
  77. :cond_2
  78. new-instance v0, Ljava/net/ProtocolException;
  79. new-instance v1, Ljava/lang/StringBuilder;
  80. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  81. invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  82. invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  83. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  84. move-result-object p0
  85. invoke-direct {v0, p0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  86. throw v0
  87. :cond_3
  88. const-string v0, "ICY "
  89. invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  90. move-result v0
  91. if-eqz v0, :cond_7
  92. sget-object v0, Lokhttp3/Protocol;->HTTP_1_0:Lokhttp3/Protocol;
  93. const/4 v3, 0x4
  94. :goto_0
  95. invoke-virtual {p0}, Ljava/lang/String;->length()I
  96. move-result v5
  97. add-int/lit8 v6, v3, 0x3
  98. if-lt v5, v6, :cond_6
  99. :try_start_0
  100. invoke-virtual {p0, v3, v6}, Ljava/lang/String;->substring(II)Ljava/lang/String;
  101. move-result-object v5
  102. invoke-static {v5}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
  103. move-result v5
  104. :try_end_0
  105. .catch Ljava/lang/NumberFormatException; {:try_start_0 .. :try_end_0} :catch_0
  106. invoke-virtual {p0}, Ljava/lang/String;->length()I
  107. move-result v7
  108. if-le v7, v6, :cond_5
  109. invoke-virtual {p0, v6}, Ljava/lang/String;->charAt(I)C
  110. move-result v6
  111. if-ne v6, v1, :cond_4
  112. add-int/2addr v3, v2
  113. invoke-virtual {p0, v3}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  114. move-result-object p0
  115. goto :goto_1
  116. :cond_4
  117. new-instance v0, Ljava/net/ProtocolException;
  118. new-instance v1, Ljava/lang/StringBuilder;
  119. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  120. invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  121. invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  122. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  123. move-result-object p0
  124. invoke-direct {v0, p0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  125. throw v0
  126. :cond_5
  127. const-string p0, ""
  128. :goto_1
  129. new-instance v1, Lokhttp3/internal/http/StatusLine;
  130. invoke-direct {v1, v0, v5, p0}, Lokhttp3/internal/http/StatusLine;-><init>(Lokhttp3/Protocol;ILjava/lang/String;)V
  131. return-object v1
  132. :catch_0
  133. new-instance v0, Ljava/net/ProtocolException;
  134. new-instance v1, Ljava/lang/StringBuilder;
  135. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  136. invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  137. invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  138. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  139. move-result-object p0
  140. invoke-direct {v0, p0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  141. throw v0
  142. :cond_6
  143. new-instance v0, Ljava/net/ProtocolException;
  144. new-instance v1, Ljava/lang/StringBuilder;
  145. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  146. invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  147. invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  148. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  149. move-result-object p0
  150. invoke-direct {v0, p0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  151. throw v0
  152. :cond_7
  153. new-instance v0, Ljava/net/ProtocolException;
  154. new-instance v1, Ljava/lang/StringBuilder;
  155. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  156. invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  157. invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  158. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  159. move-result-object p0
  160. invoke-direct {v0, p0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
  161. throw v0
  162. .end method
  163. # virtual methods
  164. .method public toString()Ljava/lang/String;
  165. .locals 3
  166. new-instance v0, Ljava/lang/StringBuilder;
  167. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  168. iget-object v1, p0, Lokhttp3/internal/http/StatusLine;->protocol:Lokhttp3/Protocol;
  169. sget-object v2, Lokhttp3/Protocol;->HTTP_1_0:Lokhttp3/Protocol;
  170. if-ne v1, v2, :cond_0
  171. const-string v1, "HTTP/1.0"
  172. goto :goto_0
  173. :cond_0
  174. const-string v1, "HTTP/1.1"
  175. :goto_0
  176. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  177. const/16 v1, 0x20
  178. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
  179. iget v2, p0, Lokhttp3/internal/http/StatusLine;->code:I
  180. invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  181. iget-object v2, p0, Lokhttp3/internal/http/StatusLine;->message:Ljava/lang/String;
  182. if-eqz v2, :cond_1
  183. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
  184. iget-object v1, p0, Lokhttp3/internal/http/StatusLine;->message:Ljava/lang/String;
  185. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  186. :cond_1
  187. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  188. move-result-object v0
  189. return-object v0
  190. .end method