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);
}
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);
}
} 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;
}