|
|
@ -59,12 +59,19 @@ class AnalyzeUrl( |
|
|
|
private var requestBody: RequestBody? = null |
|
|
|
private var requestBody: RequestBody? = null |
|
|
|
private var method = RequestMethod.GET |
|
|
|
private var method = RequestMethod.GET |
|
|
|
private val splitUrlRegex = Regex(",\\s*(?=\\{)") |
|
|
|
private val splitUrlRegex = Regex(",\\s*(?=\\{)") |
|
|
|
|
|
|
|
private var proxy: String? = null |
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
init { |
|
|
|
baseUrl?.let { |
|
|
|
baseUrl?.let { |
|
|
|
this.baseUrl = it.split(splitUrlRegex, 1)[0] |
|
|
|
this.baseUrl = it.split(splitUrlRegex, 1)[0] |
|
|
|
} |
|
|
|
} |
|
|
|
headerMapF?.let { headerMap.putAll(it) } |
|
|
|
headerMapF?.let { |
|
|
|
|
|
|
|
headerMap.putAll(it) |
|
|
|
|
|
|
|
if (it.containsKey("proxy")) { |
|
|
|
|
|
|
|
proxy = it["proxy"]; |
|
|
|
|
|
|
|
headerMap.remove("proxy") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//替换参数 |
|
|
|
//替换参数 |
|
|
|
analyzeJs(key, page, speakText, speakSpeed, book) |
|
|
|
analyzeJs(key, page, speakText, speakSpeed, book) |
|
|
|
replaceKeyPageJs(key, page, speakText, speakSpeed, book) |
|
|
|
replaceKeyPageJs(key, page, speakText, speakSpeed, book) |
|
|
@ -329,21 +336,52 @@ class AnalyzeUrl( |
|
|
|
val res = when { |
|
|
|
val res = when { |
|
|
|
method == RequestMethod.POST -> { |
|
|
|
method == RequestMethod.POST -> { |
|
|
|
if (fieldMap.isNotEmpty()) { |
|
|
|
if (fieldMap.isNotEmpty()) { |
|
|
|
|
|
|
|
if (proxy == null) { |
|
|
|
HttpHelper |
|
|
|
HttpHelper |
|
|
|
.getApiService<HttpPostApi>(baseUrl, charset) |
|
|
|
.getApiService<HttpPostApi>(baseUrl, charset) |
|
|
|
.postMapAsync(url, fieldMap, headerMap) |
|
|
|
.postMapAsync(url, fieldMap, headerMap) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
HttpHelper |
|
|
|
|
|
|
|
.getApiServiceWithProxy<HttpPostApi>(baseUrl, charset, proxy) |
|
|
|
|
|
|
|
.postMapAsync(url, fieldMap, headerMap) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (proxy == null) { |
|
|
|
HttpHelper |
|
|
|
HttpHelper |
|
|
|
.getApiService<HttpPostApi>(baseUrl, charset) |
|
|
|
.getApiService<HttpPostApi>(baseUrl, charset) |
|
|
|
.postBodyAsync(url, requestBody!!, headerMap) |
|
|
|
.postBodyAsync(url, requestBody!!, headerMap) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
HttpHelper |
|
|
|
|
|
|
|
.getApiServiceWithProxy<HttpPostApi>(baseUrl, charset, proxy) |
|
|
|
|
|
|
|
.postBodyAsync(url, requestBody!!, headerMap) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
fieldMap.isEmpty() -> HttpHelper |
|
|
|
} |
|
|
|
|
|
|
|
fieldMap.isEmpty() -> { |
|
|
|
|
|
|
|
if (proxy == null) { |
|
|
|
|
|
|
|
HttpHelper |
|
|
|
.getApiService<HttpGetApi>(baseUrl, charset) |
|
|
|
.getApiService<HttpGetApi>(baseUrl, charset) |
|
|
|
.getAsync(url, headerMap) |
|
|
|
.getAsync(url, headerMap) |
|
|
|
else -> HttpHelper |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
HttpHelper |
|
|
|
|
|
|
|
.getApiServiceWithProxy<HttpGetApi>(baseUrl, charset, proxy) |
|
|
|
|
|
|
|
.getAsync(url, headerMap) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
|
|
if (proxy == null) { |
|
|
|
|
|
|
|
HttpHelper |
|
|
|
.getApiService<HttpGetApi>(baseUrl, charset) |
|
|
|
.getApiService<HttpGetApi>(baseUrl, charset) |
|
|
|
.getMapAsync(url, fieldMap, headerMap) |
|
|
|
.getMapAsync(url, fieldMap, headerMap) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
HttpHelper |
|
|
|
|
|
|
|
.getApiServiceWithProxy<HttpGetApi>(baseUrl, charset, proxy) |
|
|
|
|
|
|
|
.getMapAsync(url, fieldMap, headerMap) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return Res(NetworkUtils.getUrl(res), res.body()) |
|
|
|
return Res(NetworkUtils.getUrl(res), res.body()) |
|
|
|
} |
|
|
|
} |
|
|
|