fix(接口测试): 修复参数名编码不生效的缺陷

--bug=1020647 --user=王孝刚 【接口测试】请求参数-参数名编码没生效
https://www.tapd.cn/55049933/s/1314352
This commit is contained in:
wxg0103 2022-12-08 17:28:09 +08:00 committed by fit2-zhao
parent 67b10f5277
commit 047c1b6579
1 changed files with 5 additions and 4 deletions

View File

@ -554,8 +554,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
try {
String value = keyValue.getValue() != null && keyValue.getValue().startsWith("@") ?
ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
value = keyValue.isUrlEncode() ? "${__urlencode(" + value + ")}" : value;
keyValueMap.put(keyValue.getName(), value);
value = keyValue.isUrlEncode() ? StringUtils.join(StringUtils.join("${__urlencode(", value), ")}") : value;
String key = keyValue.isUrlEncode() ? StringUtils.join(StringUtils.join("${__urlencode(", keyValue.getName()), ")}") : keyValue.getName();
keyValueMap.put(key, value);
} catch (Exception e) {
LogUtil.error(e);
}
@ -585,11 +586,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
stringBuffer.append("?");
}
this.getArguments().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue -> {
stringBuffer.append(keyValue.getName());
stringBuffer.append(keyValue.isUrlEncode() ? StringUtils.join(StringUtils.join("${__urlencode(", keyValue.getName()), ")}") : keyValue.getName());
if (keyValue.getValue() != null) {
try {
String value = keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
value = keyValue.isUrlEncode() ? "${__urlencode(" + value + ")}" : value;
value = keyValue.isUrlEncode() ? StringUtils.join(StringUtils.join("${__urlencode(", value), ")}") : value;
if (StringUtils.isNotEmpty(value) && value.contains(StringUtils.CR)) {
value = value.replaceAll(StringUtils.CR, StringUtils.EMPTY);
}