refactor(接口测试): 接口定义导入 har 文件报错修复

--bug=1009828 --user=周骏弘 【接口测试】github#9732,导入har包报错 https://www.tapd.cn/55049933/s/1099430
This commit is contained in:
junhong 2022-01-26 17:13:09 +08:00 committed by zhangdahai112
parent 3dd81a000d
commit 3bc4fe38ad
2 changed files with 8 additions and 3 deletions

View File

@ -243,9 +243,11 @@ public class HarParser extends HarAbstractParser {
return; return;
} }
String contentType = content.mimeType; String contentType = content.mimeType;
if(body != null){
body.setType(getBodyType(contentType)); body.setType(getBodyType(contentType));
body.setRaw(content.text); body.setRaw(content.text);
} }
}
private String parseXmlBody(String xmlString) { private String parseXmlBody(String xmlString) {
JSONObject object = JSONObject.parseObject(getDefaultStringValue(xmlString)); JSONObject object = JSONObject.parseObject(getDefaultStringValue(xmlString));

View File

@ -37,10 +37,13 @@ public class Body {
public boolean isValid() { public boolean isValid() {
if (this.isKV()) { if (this.isKV()) {
if(kvs != null){
return kvs.stream().anyMatch(KeyValue::isValid); return kvs.stream().anyMatch(KeyValue::isValid);
}
} else { } else {
return StringUtils.isNotBlank(raw); return StringUtils.isNotBlank(raw);
} }
return false;
} }
public boolean isKV() { public boolean isKV() {