From d6a0feb4faaf454778aed26276105c4a097c00d0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Mar 2021 18:13:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8Djmx=E5=AF=BC=E5=85=A5=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E9=80=89=E9=A1=B9=E4=B8=8D=E8=83=BD=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/automation/parse/MsJmeterParser.java | 10 ++++------ .../java/io/metersphere/api/dto/scenario/Body.java | 8 ++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java index 0ce4456848..7cb52c524c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java @@ -136,6 +136,8 @@ public class MsJmeterParser extends ApiImportAbstractParser { try { HTTPSamplerProxy source = (HTTPSamplerProxy) key; BeanUtils.copyBean(samplerProxy, source); + samplerProxy.setRest(new ArrayList(){{this.add(new KeyValue());}}); + samplerProxy.setArguments(new ArrayList(){{this.add(new KeyValue());}}); if (source != null && source.getHTTPFiles().length > 0) { samplerProxy.getBody().initBinary(); samplerProxy.getBody().setType(Body.FORM_DATA); @@ -153,12 +155,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { keyValue.setFiles(files); keyValues.add(keyValue); } - if (source.getPostBodyRaw() && CollectionUtils.isNotEmpty(keyValues)) { - samplerProxy.getBody().setType(Body.RAW); - samplerProxy.getBody().setRaw(keyValues.get(0).getValue()); - } else { - samplerProxy.getBody().setKvs(keyValues); - } + samplerProxy.getBody().setKvs(keyValues); } samplerProxy.setProtocol(RequestType.HTTP); samplerProxy.setPort(source.getPort() + ""); @@ -168,6 +165,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { source.getArguments().getArgumentsAsMap().forEach((k, v) -> { samplerProxy.getBody().setRaw(v); }); + samplerProxy.getBody().initKvs(); } else { List keyValues = new LinkedList<>(); source.getArguments().getArgumentsAsMap().forEach((k, v) -> { 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 cabfccc0c4..4ae0e7d279 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 @@ -66,12 +66,8 @@ public class Body { sampler.setDoMultipart(true); } } else { - if (!this.isJson()) { - sampler.setPostBodyRaw(true); - } else { - if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) { - this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); - } + if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) { + this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); } KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); sampler.setPostBodyRaw(true);