fix: query参数可以传空值

This commit is contained in:
chenjianxing 2021-02-01 13:40:57 +08:00
parent faaf58decf
commit 5d167e10d5
2 changed files with 9 additions and 5 deletions

View File

@ -272,10 +272,14 @@ public class MsHTTPSamplerProxy extends MsTestElement {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(path);
stringBuffer.append("?");
this.getArguments().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue ->
stringBuffer.append(keyValue.getName()).append("=").append(keyValue.getValue() != null && keyValue.getValue().startsWith("@") ?
ScriptEngineUtils.calculate(keyValue.getValue()) : keyValue.getValue()).append("&")
);
this.getArguments().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue -> {
stringBuffer.append(keyValue.getName());
if (keyValue.getValue() != null) {
stringBuffer.append("=").append(keyValue.getValue().startsWith("@") ?
ScriptEngineUtils.calculate(keyValue.getValue()) : keyValue.getValue());
}
stringBuffer.append("&");
});
return stringBuffer.substring(0, stringBuffer.length() - 1);
}

View File

@ -57,7 +57,7 @@ public class KeyValue {
}
public boolean isValid() {
return ((StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) || "JSON-SCHEMA".equals(type)) && !StringUtils.equalsIgnoreCase(type, "file");
return (StringUtils.isNotBlank(name) || "JSON-SCHEMA".equals(type)) && !StringUtils.equalsIgnoreCase(type, "file");
}
public boolean isFile() {