|
|
@ -46,6 +46,7 @@ class AnalyzeUrl( |
|
|
|
private val queryMap = LinkedHashMap<String, String>() |
|
|
|
private val queryMap = LinkedHashMap<String, String>() |
|
|
|
private val headerMap = HashMap<String, String>() |
|
|
|
private val headerMap = HashMap<String, String>() |
|
|
|
private var charset: String? = null |
|
|
|
private var charset: String? = null |
|
|
|
|
|
|
|
private var bodyTxt: String? = null |
|
|
|
var body: RequestBody? = null |
|
|
|
var body: RequestBody? = null |
|
|
|
private set |
|
|
|
private set |
|
|
|
var method = Method.GET |
|
|
|
var method = Method.GET |
|
|
@ -121,7 +122,7 @@ class AnalyzeUrl( |
|
|
|
* 处理URL |
|
|
|
* 处理URL |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun initUrl() { |
|
|
|
private fun initUrl() { |
|
|
|
val urlArray = ruleUrl.split(",[^\\{]*".toRegex(), 2) |
|
|
|
var urlArray = ruleUrl.split(",[^\\{]*".toRegex(), 2) |
|
|
|
url = urlArray[0] |
|
|
|
url = urlArray[0] |
|
|
|
host = NetworkUtils.getBaseUrl(url) |
|
|
|
host = NetworkUtils.getBaseUrl(url) |
|
|
|
if (urlArray.size > 1) { |
|
|
|
if (urlArray.size > 1) { |
|
|
@ -133,10 +134,22 @@ class AnalyzeUrl( |
|
|
|
headers |
|
|
|
headers |
|
|
|
)?.let { headerMap.putAll(it) } |
|
|
|
)?.let { headerMap.putAll(it) } |
|
|
|
} |
|
|
|
} |
|
|
|
options["body"]?.let { } |
|
|
|
options["body"]?.let { bodyTxt = it } |
|
|
|
options["charset"]?.let { charset = it } |
|
|
|
options["charset"]?.let { charset = it } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
when (method) { |
|
|
|
|
|
|
|
Method.GET -> { |
|
|
|
|
|
|
|
urlArray = url.split("\\?".toRegex()) |
|
|
|
|
|
|
|
url = urlArray[0] |
|
|
|
|
|
|
|
if (urlArray.size > 1) { |
|
|
|
|
|
|
|
analyzePutFields(urlArray[1]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Method.POST -> { |
|
|
|
|
|
|
|
bodyTxt |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -144,9 +157,9 @@ class AnalyzeUrl( |
|
|
|
* 解析QueryMap |
|
|
|
* 解析QueryMap |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Throws(Exception::class) |
|
|
|
@Throws(Exception::class) |
|
|
|
private fun analyzeQuery(allQuery: String) { |
|
|
|
private fun analyzePutFields(fieldsTxt: String) { |
|
|
|
queryStr = allQuery |
|
|
|
queryStr = fieldsTxt |
|
|
|
val queryS = allQuery.split("&".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() |
|
|
|
val queryS = fieldsTxt.split("&".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() |
|
|
|
for (query in queryS) { |
|
|
|
for (query in queryS) { |
|
|
|
val queryM = query.split("=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() |
|
|
|
val queryM = query.split("=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() |
|
|
|
val value = if (queryM.size > 1) queryM[1] else "" |
|
|
|
val value = if (queryM.size > 1) queryM[1] else "" |
|
|
|