fix(接口测试): 修复query参数未拼接到url问题

--bug=1011784 --user=赵勇 【接口测试】场景-自定义请求,使用变量作为域名的时候,query参数拼不上 https://www.tapd.cn/55049933/s/1127331
This commit is contained in:
fit2-zhao 2022-03-29 17:14:55 +08:00 committed by 刘瑞斌
parent ab31ec2fe9
commit 76409e31b7
1 changed files with 22 additions and 27 deletions

View File

@ -466,12 +466,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
sampler.setProperty("HTTPSampler.path", envPath);
}
if (CollectionUtils.isNotEmpty(this.getArguments())) {
String path = envPath;
if (StringUtils.equalsIgnoreCase(this.getMethod(), "GET")) {
getQueryParameters(sampler);
} else {
path = postQueryParameters(envPath);
}
String path = postQueryParameters(envPath);
if (HTTPConstants.DELETE.equals(this.getMethod()) && !path.startsWith("${")) {
if (!path.startsWith("/")) {
path = "/" + path;
@ -692,28 +687,28 @@ public class MsHTTPSamplerProxy extends MsTestElement {
list.stream().
filter(KeyValue::isValid).
filter(KeyValue::isEnable).forEach(keyValue -> {
try {
String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value);
if (keyValue.getValue() == null) {
httpArgument.setValue("");
}
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
if (StringUtils.isNotBlank(keyValue.getContentType())) {
httpArgument.setContentType(keyValue.getContentType());
}
if (StringUtils.equalsIgnoreCase(this.method, "get")) {
if (StringUtils.isNotEmpty(httpArgument.getValue())) {
arguments.addArgument(httpArgument);
}
} else {
arguments.addArgument(httpArgument);
}
} catch (Exception e) {
}
try {
String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value);
if (keyValue.getValue() == null) {
httpArgument.setValue("");
}
);
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
if (StringUtils.isNotBlank(keyValue.getContentType())) {
httpArgument.setContentType(keyValue.getContentType());
}
if (StringUtils.equalsIgnoreCase(this.method, "get")) {
if (StringUtils.isNotEmpty(httpArgument.getValue())) {
arguments.addArgument(httpArgument);
}
} else {
arguments.addArgument(httpArgument);
}
} catch (Exception e) {
}
}
);
return arguments;
}