From a3ef283488f6aaa37a04d41f88aaf3c47228c44f Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 22 Nov 2021 14:22:30 +0800 Subject: [PATCH] =?UTF-8?q?fix=20(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E8=AF=B7=E6=B1=82=E5=A4=B4=E4=B8=AD?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E5=A4=9A=E4=BD=99=E5=8F=82=E6=95=B0=20--bug?= =?UTF-8?q?=3D1008180=20--user=3D=E8=B5=B5=E5=8B=87=20=E3=80=90github=20#7?= =?UTF-8?q?881=E3=80=91HTTP=E8=AF=B7=E6=B1=82=E9=BB=98=E8=AE=A4=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86"content-type":"text/plain;=20charset=3DUTF-8?= =?UTF-8?q?"=E7=9A=84=E8=AF=B7=E6=B1=82=E5=A4=B4=20https://www.tapd.cn/550?= =?UTF-8?q?49933/s/1071783?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/sampler/MsHTTPSamplerProxy.java | 5 ++++- .../java/io/metersphere/api/dto/scenario/Body.java | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index ba4ba8c637..9f3492ed91 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -237,7 +237,10 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setDoMultipart(true); } if (CollectionUtils.isNotEmpty(bodyParams)) { - sampler.setArguments(httpArguments(bodyParams)); + Arguments arguments = httpArguments(bodyParams); + if (arguments != null && !arguments.getArguments().isEmpty()) { + sampler.setArguments(arguments); + } } } 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 825d34bdcf..13e67872de 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 @@ -71,12 +71,14 @@ public class Body { sampler.setDoMultipart(true); } } else { - parseJonBodyMock(); - KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); - sampler.setPostBodyRaw(true); - keyValue.setEnable(true); - keyValue.setUrlEncode(false); - body.add(keyValue); + if(StringUtils.isNotEmpty(this.getRaw()) || this.getJsonSchema()!= null ) { + parseJonBodyMock(); + KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); + sampler.setPostBodyRaw(true); + keyValue.setEnable(true); + keyValue.setUrlEncode(false); + body.add(keyValue); + } } return body; }