diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index 200b080a7c..12d127bebc 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -70,9 +70,11 @@ public class Body { public List getBodyParams(HTTPSamplerProxy sampler, String requestId) { List body = new ArrayList<>(); if (this.isKV() || this.isBinary()) { - body = this.getKvs().stream().filter(KeyValue::isValid).collect(Collectors.toList()); + if (StringUtils.equalsAnyIgnoreCase(this.type, WWW_FROM, FORM_DATA)) { + body = this.getKvs().stream().filter(KeyValue::isValid).collect(Collectors.toList()); + } + // 处理上传文件 HTTPFileArg[] httpFileArgs = httpFileArgs(requestId); - // 文件上传 if (ArrayUtils.isNotEmpty(httpFileArgs)) { sampler.setHTTPFiles(httpFileArgs(requestId)); sampler.setDoMultipart(!StringUtils.equalsIgnoreCase(this.type, "BINARY")); @@ -127,12 +129,12 @@ public class Body { private HTTPFileArg[] httpFileArgs(String requestId) { List list = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(this.getKvs())) { + if (StringUtils.equalsAnyIgnoreCase(this.type, WWW_FROM, FORM_DATA) && CollectionUtils.isNotEmpty(this.getKvs())) { this.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { setFileArg(list, keyValue.getFiles(), keyValue, requestId, false); }); } - if (CollectionUtils.isNotEmpty(this.getBinary())) { + if (StringUtils.equalsIgnoreCase(this.type, BINARY) && CollectionUtils.isNotEmpty(this.getBinary())) { this.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { setFileArg(list, keyValue.getFiles(), keyValue, requestId, true); });