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,16 +713,24 @@ 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).
if (keyValue.getValue() == null) { filter(KeyValue::isEnable).forEach(keyValue -> {
httpArgument.setValue(""); 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("");
}
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
if (StringUtils.isNotBlank(keyValue.getContentType())) {
httpArgument.setContentType(keyValue.getContentType());
}
arguments.addArgument(httpArgument);
} catch (Exception e) {
} }
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
if (StringUtils.isNotBlank(keyValue.getContentType())) {
httpArgument.setContentType(keyValue.getContentType());
}
arguments.addArgument(httpArgument);
} }
); );
return arguments; return arguments;