feat(接口测试): POST请求参数增加编码设置

--story=1003795 --user=赵勇 3.post请求参考get请求 自动转码 https://www.tapd.cn/55049933/s/1069349
This commit is contained in:
fit2-zhao 2021-11-17 17:54:20 +08:00 committed by fit2-zhao
parent 72c300cc6c
commit 9f361469f1
1 changed files with 17 additions and 9 deletions

View File

@ -713,8 +713,13 @@ public class MsHTTPSamplerProxy extends MsTestElement {
private Arguments httpArguments(List<KeyValue> list) { private Arguments httpArguments(List<KeyValue> list) {
Arguments arguments = new Arguments(); Arguments arguments = new Arguments();
list.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> { list.stream().
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue()); filter(KeyValue::isValid).
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) { if (keyValue.getValue() == null) {
httpArgument.setValue(""); httpArgument.setValue("");
} }
@ -723,6 +728,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
httpArgument.setContentType(keyValue.getContentType()); httpArgument.setContentType(keyValue.getContentType());
} }
arguments.addArgument(httpArgument); arguments.addArgument(httpArgument);
} catch (Exception e) {
}
} }
); );
return arguments; return arguments;