mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 12:09:13 +08:00
fix(接口测试): 导入请求体格式是json的jmx格式的接口,导入后默认请求体格式是raw
--bug=1010910 --user=李玉号 【接口测试】github#11218,【接口测试】导入请求体格式是json的jmx格式的接口,导入后默认请求体格式是raw;自定义脚本修改成json格式后导入默认请求体格式是x-www-form-urlencoded https://www.tapd.cn/55049933/s/1115431 Closes #11218
This commit is contained in:
parent
537bf150ec
commit
9411bd6fd6
@ -718,7 +718,20 @@ public class JmeterDefinitionParser extends ApiImportAbstractParser<ApiDefinitio
|
|||||||
String bodyType = this.getBodyType(samplerProxy.getHeaders());
|
String bodyType = this.getBodyType(samplerProxy.getHeaders());
|
||||||
if (source.getArguments() != null) {
|
if (source.getArguments() != null) {
|
||||||
if (source.getPostBodyRaw()) {
|
if (source.getPostBodyRaw()) {
|
||||||
samplerProxy.getBody().setType(Body.RAW);
|
List<KeyValue> headers = samplerProxy.getHeaders();
|
||||||
|
boolean jsonType = false;
|
||||||
|
if (CollectionUtils.isNotEmpty(headers)) {
|
||||||
|
for (KeyValue header : headers) {
|
||||||
|
if (StringUtils.equals(header.getName(), "Content-Type") && StringUtils.equals(header.getValue(), "application/json")) {
|
||||||
|
samplerProxy.getBody().setType(Body.JSON);
|
||||||
|
jsonType = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!jsonType) {
|
||||||
|
samplerProxy.getBody().setType(Body.RAW);
|
||||||
|
}
|
||||||
source.getArguments().getArgumentsAsMap().forEach((k, v) -> samplerProxy.getBody().setRaw(v));
|
source.getArguments().getArgumentsAsMap().forEach((k, v) -> samplerProxy.getBody().setRaw(v));
|
||||||
samplerProxy.getBody().initKvs();
|
samplerProxy.getBody().initKvs();
|
||||||
} else if (StringUtils.isNotEmpty(bodyType) || ("POST".equalsIgnoreCase(source.getMethod()) && source.getArguments().getArgumentsAsMap().size() > 0)) {
|
} else if (StringUtils.isNotEmpty(bodyType) || ("POST".equalsIgnoreCase(source.getMethod()) && source.getArguments().getArgumentsAsMap().size() > 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user