From f5bd24f410e8f5bfa9dea856545d018b30378019 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 19 Oct 2023 16:16:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E5=93=8D=E5=BA=94=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E5=AF=B9=E5=BA=94=E7=9A=84=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1032155 --user=王孝刚 【接口测试】HTML、XML格式的响应未自动匹配对应的格式化选项 https://www.tapd.cn/55049933/s/1428544 --- .../src/business/commons/MsDropdown.vue | 5 +++++ .../components/response/ResponseResult.vue | 17 +++++++++++++++++ .../java/io/metersphere/jmeter/JMeterBase.java | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/api-test/frontend/src/business/commons/MsDropdown.vue b/api-test/frontend/src/business/commons/MsDropdown.vue index 7ff49490ba..2b737839b3 100644 --- a/api-test/frontend/src/business/commons/MsDropdown.vue +++ b/api-test/frontend/src/business/commons/MsDropdown.vue @@ -37,6 +37,11 @@ export default { this.currentCommand = this.commands[0]; } }, + watch: { + defaultCommand(val) { + this.currentCommand = val; + }, + }, methods: { handleCommand(command) { this.currentCommand = command; diff --git a/api-test/frontend/src/business/definition/components/response/ResponseResult.vue b/api-test/frontend/src/business/definition/components/response/ResponseResult.vue index 5766d966d3..8c9e2fa8d5 100644 --- a/api-test/frontend/src/business/definition/components/response/ResponseResult.vue +++ b/api-test/frontend/src/business/definition/components/response/ResponseResult.vue @@ -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; diff --git a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/jmeter/JMeterBase.java b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/jmeter/JMeterBase.java index eb2647df8f..963a9080a8 100644 --- a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/jmeter/JMeterBase.java +++ b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/jmeter/JMeterBase.java @@ -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());