fix (接口测试): 支持GET和POST请求,变量参数urlencode

--bug=1008320 --user=赵勇 【github #8066】query参数选择编码后没有替换变量值 https://www.tapd.cn/55049933/s/1074205
This commit is contained in:
fit2-zhao 2021-11-24 15:38:18 +08:00 committed by fit2-zhao
parent ea52fe185c
commit 15508b0e86
1 changed files with 2 additions and 3 deletions

View File

@ -677,7 +677,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
try {
String value = keyValue.getValue() != null && keyValue.getValue().startsWith("@") ?
ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
value = keyValue.isUrlEncode() ? URLEncoder.encode(value, "utf-8") : value;
value = keyValue.isUrlEncode() ? "${__urlencode(" + value + ")}" : value;
keyValueMap.put(keyValue.getName(), value);
} catch (Exception e) {
LogUtil.error(e);
@ -708,7 +708,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
if (keyValue.getValue() != null) {
try {
String value = keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
value = keyValue.isUrlEncode() ? URLEncoder.encode(value, "utf-8") : value;
value = keyValue.isUrlEncode() ? "${__urlencode(" + value + ")}" : value;
stringBuffer.append("=").append(value);
} catch (Exception e) {
LogUtil.error(e);
@ -726,7 +726,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
filter(KeyValue::isEnable).forEach(keyValue -> {
try {
String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
value = keyValue.isUrlEncode() ? URLEncoder.encode(value, "utf-8") : value;
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value);
if (keyValue.getValue() == null) {
httpArgument.setValue("");