fix (接口测试): 修复请求头中包含多余参数

--bug=1008180 --user=赵勇 【github #7881】HTTP请求默认添加了"content-type":"text/plain; charset=UTF-8"的请求头 https://www.tapd.cn/55049933/s/1071783
This commit is contained in:
fit2-zhao 2021-11-22 14:22:30 +08:00 committed by fit2-zhao
parent 93a89f32e7
commit a3ef283488
2 changed files with 12 additions and 7 deletions

View File

@ -237,7 +237,10 @@ public class MsHTTPSamplerProxy extends MsTestElement {
sampler.setDoMultipart(true); sampler.setDoMultipart(true);
} }
if (CollectionUtils.isNotEmpty(bodyParams)) { if (CollectionUtils.isNotEmpty(bodyParams)) {
sampler.setArguments(httpArguments(bodyParams)); Arguments arguments = httpArguments(bodyParams);
if (arguments != null && !arguments.getArguments().isEmpty()) {
sampler.setArguments(arguments);
}
} }
} }

View File

@ -71,12 +71,14 @@ public class Body {
sampler.setDoMultipart(true); sampler.setDoMultipart(true);
} }
} else { } else {
parseJonBodyMock(); if(StringUtils.isNotEmpty(this.getRaw()) || this.getJsonSchema()!= null ) {
KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); parseJonBodyMock();
sampler.setPostBodyRaw(true); KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true);
keyValue.setEnable(true); sampler.setPostBodyRaw(true);
keyValue.setUrlEncode(false); keyValue.setEnable(true);
body.add(keyValue); keyValue.setUrlEncode(false);
body.add(keyValue);
}
} }
return body; return body;
} }