refactor(接口测试): 接口响应自动匹配对应的格式化选项

--bug=1032155 --user=王孝刚 【接口测试】HTML、XML格式的响应未自动匹配对应的格式化选项
https://www.tapd.cn/55049933/s/1428544
This commit is contained in:
wxg0103 2023-10-19 16:16:13 +08:00 committed by 刘瑞斌
parent dd2054dc6f
commit f5bd24f410
3 changed files with 23 additions and 1 deletions

View File

@ -37,6 +37,11 @@ export default {
this.currentCommand = this.commands[0];
}
},
watch: {
defaultCommand(val) {
this.currentCommand = val;
},
},
methods: {
handleCommand(command) {
this.currentCommand = command;

View File

@ -179,6 +179,23 @@ export default {
}
});
}
if (this.response && this.response.responseResult && this.response.responseResult.contentType) {
switch (this.response.responseResult.contentType) {
case 'application/json':
this.mode = BODY_FORMAT.JSON;
break;
case 'text/html':
this.mode = BODY_FORMAT.HTML;
break;
case 'text/xml':
this.mode = BODY_FORMAT.XML;
break;
default:
this.mode = BODY_FORMAT.TEXT;
break;
}
}
this.msCodeReload();
},
msCodeReload() {
this.isMsCodeEditShow = false;

View File

@ -107,11 +107,11 @@ public class JMeterBase {
//判断返回的类型是否是图片
LoggerUtil.info("返回内容类型为【" + result.getContentType() + "");
if (StringUtils.isNotEmpty(result.getContentType()) && imageList.contains(result.getContentType())) {
responseResult.setContentType(result.getContentType());
responseResult.setImageUrl(result.getResponseData());
}
responseResult.setBody(result.getResponseDataAsString());
}
responseResult.setContentType(result.getContentType());
responseResult.setHeaders(result.getResponseHeaders());
responseResult.setLatency(result.getLatency());
responseResult.setResponseCode(result.getResponseCode());