pull/32/head
kunfei 5 years ago
parent e0453a5547
commit dd4fa27856
  1. 4
      app/src/main/java/io/legado/app/data/api/IHttpGetApi.kt
  2. 4
      app/src/main/java/io/legado/app/data/api/IHttpPostApi.kt
  3. 2
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  4. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -31,12 +31,12 @@ interface IHttpGetApi {
fun get( fun get(
@Url url: String, @Url url: String,
@HeaderMap headers: Map<String, String> @HeaderMap headers: Map<String, String>
): Call<Response<String>> ): Call<String>
@GET @GET
fun getMap( fun getMap(
@Url url: String, @Url url: String,
@QueryMap(encoded = true) queryMap: Map<String, String>, @QueryMap(encoded = true) queryMap: Map<String, String>,
@HeaderMap headers: Map<String, String> @HeaderMap headers: Map<String, String>
): Call<Response<String>> ): Call<String>
} }

@ -34,12 +34,12 @@ interface IHttpPostApi {
@Url url: String, @Url url: String,
@FieldMap(encoded = true) fieldMap: Map<String, String>, @FieldMap(encoded = true) fieldMap: Map<String, String>,
@HeaderMap headers: Map<String, String> @HeaderMap headers: Map<String, String>
): Call<Response<String>> ): Call<String>
@POST @POST
fun postBody( fun postBody(
@Url url: String, @Url url: String,
@Body body: RequestBody, @Body body: RequestBody,
@HeaderMap headers: Map<String, String> @HeaderMap headers: Map<String, String>
): Call<Response<String>> ): Call<String>
} }

@ -17,7 +17,7 @@ class JsExtensions {
val analyzeUrl = AnalyzeUrl(urlStr, null, null, null, null, null) val analyzeUrl = AnalyzeUrl(urlStr, null, null, null, null, null)
val call = analyzeUrl.getResponse() val call = analyzeUrl.getResponse()
val response = call.execute() val response = call.execute()
response.body()?.toString() response.body()
} catch (e: Exception) { } catch (e: Exception) {
e.localizedMessage e.localizedMessage
} }

@ -200,7 +200,7 @@ class AnalyzeUrl(
GET, POST GET, POST
} }
fun getResponse(): Call<Response<String>> { fun getResponse(): Call<String> {
return when { return when {
method == Method.POST -> { method == Method.POST -> {
if (fieldMap.isNotEmpty()) { if (fieldMap.isNotEmpty()) {

Loading…
Cancel
Save