pull/32/head
parent
f56ad432d2
commit
44ab6dc900
@ -0,0 +1,27 @@ |
||||
package io.legado.app.data.api; |
||||
|
||||
import java.util.Map; |
||||
|
||||
import kotlinx.coroutines.Deferred; |
||||
import retrofit2.Response; |
||||
import retrofit2.http.GET; |
||||
import retrofit2.http.HeaderMap; |
||||
import retrofit2.http.QueryMap; |
||||
import retrofit2.http.Url; |
||||
|
||||
/** |
||||
* Created by GKF on 2018/1/21. |
||||
* get web content |
||||
*/ |
||||
|
||||
public interface IHttpGetApi { |
||||
@GET |
||||
Deferred<Response<String>> get(@Url String url, |
||||
@HeaderMap Map<String, String> headers); |
||||
|
||||
@GET |
||||
Deferred<Response<String>> getMap(@Url String url, |
||||
@QueryMap(encoded = true) Map<String, String> queryMap, |
||||
@HeaderMap Map<String, String> headers); |
||||
|
||||
} |
@ -0,0 +1,33 @@ |
||||
package io.legado.app.data.api; |
||||
|
||||
import java.util.Map; |
||||
|
||||
import kotlinx.coroutines.Deferred; |
||||
import okhttp3.RequestBody; |
||||
import retrofit2.Response; |
||||
import retrofit2.http.Body; |
||||
import retrofit2.http.FieldMap; |
||||
import retrofit2.http.FormUrlEncoded; |
||||
import retrofit2.http.HeaderMap; |
||||
import retrofit2.http.POST; |
||||
import retrofit2.http.Url; |
||||
|
||||
/** |
||||
* Created by GKF on 2018/1/29. |
||||
* post |
||||
*/ |
||||
|
||||
public interface IHttpPostApi { |
||||
|
||||
@FormUrlEncoded |
||||
@POST |
||||
Deferred<Response<String>> postMap(@Url String url, |
||||
@FieldMap(encoded = true) Map<String, String> fieldMap, |
||||
@HeaderMap Map<String, String> headers); |
||||
|
||||
@FormUrlEncoded |
||||
@POST |
||||
Deferred<Response<String>> postJson(@Url String url, |
||||
@Body RequestBody body, |
||||
@HeaderMap Map<String, String> headers); |
||||
} |
@ -1,37 +0,0 @@ |
||||
package io.legado.app.model.analyzeRule |
||||
|
||||
import android.text.TextUtils.isEmpty |
||||
import io.legado.app.App |
||||
import io.legado.app.R |
||||
import io.legado.app.data.entities.BookSource |
||||
import io.legado.app.utils.GSON |
||||
import io.legado.app.utils.fromJsonObject |
||||
import io.legado.app.utils.getPrefString |
||||
import java.util.* |
||||
|
||||
/** |
||||
* Created by GKF on 2018/3/2. |
||||
* 解析Headers |
||||
*/ |
||||
|
||||
object AnalyzeHeaders { |
||||
|
||||
private val defaultUserAgent: String |
||||
get() = App.INSTANCE.getPrefString("user_agent") |
||||
?: App.INSTANCE.getString(R.string.pv_user_agent) |
||||
|
||||
fun getMap(bookSource: BookSource?): Map<String, String> { |
||||
val headerMap = HashMap<String, String>() |
||||
if (bookSource != null && !isEmpty(bookSource.header)) { |
||||
bookSource.header?.let { |
||||
val map: HashMap<String, String>? = GSON.fromJsonObject<HashMap<String, String>>(it) |
||||
map?.let { headerMap.putAll(map) } |
||||
} |
||||
} |
||||
if (bookSource != null) { |
||||
val cookie = App.db.sourceCookieDao().getCookieByUrl(bookSource.bookSourceUrl) |
||||
cookie?.let { headerMap["Cookie"] = cookie } |
||||
} |
||||
return headerMap |
||||
} |
||||
} |
Loading…
Reference in new issue