|
|
@ -169,28 +169,21 @@ class AnalyzeUrl( |
|
|
|
if (urlNoOption.length != ruleUrl.length) { |
|
|
|
if (urlNoOption.length != ruleUrl.length) { |
|
|
|
GSON.fromJsonObject<UrlOption>(ruleUrl.substring(urlMatcher.end())).getOrNull() |
|
|
|
GSON.fromJsonObject<UrlOption>(ruleUrl.substring(urlMatcher.end())).getOrNull() |
|
|
|
?.let { option -> |
|
|
|
?.let { option -> |
|
|
|
option.method?.let { |
|
|
|
option.getMethod()?.let { |
|
|
|
if (it.equals("POST", true)) method = RequestMethod.POST |
|
|
|
if (it.equals("POST", true)) method = RequestMethod.POST |
|
|
|
} |
|
|
|
} |
|
|
|
option.headers?.let { headers -> |
|
|
|
option.getHeaders()?.forEach { entry -> |
|
|
|
if (headers is Map<*, *>) { |
|
|
|
|
|
|
|
headers.forEach { entry -> |
|
|
|
|
|
|
|
headerMap[entry.key.toString()] = entry.value.toString() |
|
|
|
headerMap[entry.key.toString()] = entry.value.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (headers is String) { |
|
|
|
option.getBody()?.let { |
|
|
|
GSON.fromJsonObject<Map<String, String>>(headers).getOrNull() |
|
|
|
body = it |
|
|
|
?.let { headerMap.putAll(it) } |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
type = option.getType() |
|
|
|
option.body?.let { |
|
|
|
charset = option.getCharset() |
|
|
|
body = if (it is String) it else GSON.toJson(it) |
|
|
|
retry = option.getRetry() |
|
|
|
} |
|
|
|
|
|
|
|
type = option.type |
|
|
|
|
|
|
|
charset = option.charset |
|
|
|
|
|
|
|
retry = option.retry |
|
|
|
|
|
|
|
useWebView = option.useWebView() |
|
|
|
useWebView = option.useWebView() |
|
|
|
webJs = option.webJs |
|
|
|
webJs = option.getWebJs() |
|
|
|
option.js?.let { jsStr -> |
|
|
|
option.getJs()?.let { jsStr -> |
|
|
|
evalJS(jsStr, url)?.toString()?.let { |
|
|
|
evalJS(jsStr, url)?.toString()?.let { |
|
|
|
url = it |
|
|
|
url = it |
|
|
|
} |
|
|
|
} |
|
|
@ -561,16 +554,47 @@ class AnalyzeUrl( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data class UrlOption( |
|
|
|
data class UrlOption( |
|
|
|
var method: String? = null, |
|
|
|
private var method: String? = null, |
|
|
|
var charset: String? = null, |
|
|
|
private var charset: String? = null, |
|
|
|
var headers: Any? = null, |
|
|
|
private var headers: Any? = null, |
|
|
|
var body: Any? = null, |
|
|
|
private var body: Any? = null, |
|
|
|
var type: String? = null, |
|
|
|
private var type: String? = null, |
|
|
|
var js: String? = null, |
|
|
|
private var retry: Int? = null, |
|
|
|
var retry: Int = 0, |
|
|
|
private var webView: Any? = null, |
|
|
|
var webView: Any? = null, |
|
|
|
private var webJs: String? = null, |
|
|
|
var webJs: String? = null, |
|
|
|
private var js: String? = null, |
|
|
|
) { |
|
|
|
) { |
|
|
|
|
|
|
|
fun setMethod(value: String?) { |
|
|
|
|
|
|
|
method = if (value.isNullOrBlank()) null else value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getMethod(): String? { |
|
|
|
|
|
|
|
return method |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setCharset(value: String?) { |
|
|
|
|
|
|
|
charset = if (value.isNullOrBlank()) null else value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getCharset(): String? { |
|
|
|
|
|
|
|
return charset |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setType(value: String?) { |
|
|
|
|
|
|
|
type = if (value.isNullOrBlank()) null else value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getType(): String? { |
|
|
|
|
|
|
|
return type |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setRetry(value: Int?) { |
|
|
|
|
|
|
|
retry = if (value == null || value <= 0) null else value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getRetry(): Int { |
|
|
|
|
|
|
|
return retry ?: 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun useWebView(): Boolean { |
|
|
|
fun useWebView(): Boolean { |
|
|
|
return when (webView) { |
|
|
|
return when (webView) { |
|
|
@ -579,6 +603,56 @@ class AnalyzeUrl( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun useWebView(boolean: Boolean) { |
|
|
|
|
|
|
|
webView = if (boolean) true else null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setHeaders(value: String?) { |
|
|
|
|
|
|
|
headers = if (value.isNullOrBlank()) { |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
GSON.fromJsonObject<Map<String, Any>>(value).getOrNull() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getHeaders(): Map<*, *>? { |
|
|
|
|
|
|
|
return when (val value = headers) { |
|
|
|
|
|
|
|
is Map<*, *> -> value |
|
|
|
|
|
|
|
is String -> GSON.fromJsonObject<Map<String, Any>>(value).getOrNull() |
|
|
|
|
|
|
|
else -> null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setBody(value: String?) { |
|
|
|
|
|
|
|
body = when { |
|
|
|
|
|
|
|
value.isNullOrBlank() -> null |
|
|
|
|
|
|
|
value.isJsonObject() -> GSON.fromJsonObject<Map<String, Any>>(value) |
|
|
|
|
|
|
|
value.isJsonArray() -> GSON.fromJsonArray<Map<String, Any>>(value) |
|
|
|
|
|
|
|
else -> value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getBody(): String? { |
|
|
|
|
|
|
|
return body?.let { |
|
|
|
|
|
|
|
if (it is String) it else GSON.toJson(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setWebJs(value: String?) { |
|
|
|
|
|
|
|
webJs = if (value.isNullOrBlank()) null else value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getWebJs(): String? { |
|
|
|
|
|
|
|
return webJs |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setJs(value: String?) { |
|
|
|
|
|
|
|
js = if (value.isNullOrBlank()) null else value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getJs(): String? { |
|
|
|
|
|
|
|
return js |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data class ConcurrentRecord( |
|
|
|
data class ConcurrentRecord( |
|
|
|