From 3bc4fe38ad52f43e5d52ecabd85490457ed34f47 Mon Sep 17 00:00:00 2001 From: junhong Date: Wed, 26 Jan 2022 17:13:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=E5=AF=BC=E5=85=A5=20har?= =?UTF-8?q?=20=E6=96=87=E4=BB=B6=E6=8A=A5=E9=94=99=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009828 --user=周骏弘 【接口测试】github#9732,导入har包报错 https://www.tapd.cn/55049933/s/1099430 --- .../io/metersphere/api/dto/definition/parse/HarParser.java | 6 ++++-- .../src/main/java/io/metersphere/api/dto/scenario/Body.java | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/HarParser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/HarParser.java index fc9f9134ce..b02b980719 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/HarParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/HarParser.java @@ -243,8 +243,10 @@ public class HarParser extends HarAbstractParser { return; } String contentType = content.mimeType; - body.setType(getBodyType(contentType)); - body.setRaw(content.text); + if(body != null){ + body.setType(getBodyType(contentType)); + body.setRaw(content.text); + } } private String parseXmlBody(String xmlString) { 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 9ba783caa6..19a2aa783d 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 @@ -37,10 +37,13 @@ public class Body { public boolean isValid() { if (this.isKV()) { - return kvs.stream().anyMatch(KeyValue::isValid); + if(kvs != null){ + return kvs.stream().anyMatch(KeyValue::isValid); + } } else { return StringUtils.isNotBlank(raw); } + return false; } public boolean isKV() {