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 93c26c046a..1dda201546 100644
--- a/api-test/frontend/src/business/definition/components/response/ResponseResult.vue
+++ b/api-test/frontend/src/business/definition/components/response/ResponseResult.vue
@@ -2,15 +2,22 @@
-
+
+ ref="codeEdit"/>
+
+
+
+
+
+
@@ -19,7 +26,7 @@
:read-only="true"
:data.sync="responseResult.headers"
ref="codeEdit"
- v-if="activeName === 'headers'" />
+ v-if="activeName === 'headers'"/>
@@ -29,7 +36,7 @@
:data.sync="responseResult.console"
ref="codeEdit"
v-if="activeName === 'console'"
- height="calc(100vh - 300px)" />
+ height="calc(100vh - 300px)"/>
@@ -38,11 +45,11 @@
:read-only="true"
:data.sync="responseResult.console"
ref="codeEdit"
- v-if="activeName === 'console'" />
+ v-if="activeName === 'console'"/>
-
+
@@ -51,7 +58,7 @@
:read-only="true"
:data.sync="responseResult.vars"
v-if="activeName === 'label'"
- ref="codeEdit" />
+ ref="codeEdit"/>
@@ -60,7 +67,7 @@
:read-only="true"
:data.sync="reqMessages"
v-if="activeName === 'request_body'"
- ref="codeEdit" />
+ ref="codeEdit"/>
@@ -69,8 +76,8 @@
v-if="currentProtocol === 'SQL'"
:commands="sqlModes"
:default-command="mode"
- @command="sqlModeChange" />
-
+ @command="sqlModeChange"/>
+
@@ -81,8 +88,9 @@
import MsAssertionResults from './AssertionResults';
import MsCodeEdit from '../MsCodeEdit';
import MsDropdown from '../../../../business/commons/MsDropdown';
-import { BODY_FORMAT } from '../../model/ApiTestModel';
+import {BODY_FORMAT} from '../../model/ApiTestModel';
import MsSqlResultTable from './SqlResultTable';
+import {downloadByURL} from "fit2cloud-ui/src/tools/utils";
export default {
name: 'MsResponseResult',
@@ -114,12 +122,15 @@ export default {
mode: BODY_FORMAT.TEXT,
isMsCodeEditShow: true,
reqMessages: '',
+ contentType: ['image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'image/webp', 'image/svg+xml', 'image/apng', 'image/avif'],
+ srcUrl: '',
};
},
watch: {
response() {
this.setBodyType();
this.setReqMessage();
+ this.showPicture();
},
activeName: {
handler() {
@@ -143,6 +154,12 @@ export default {
sqlModeChange(mode) {
this.mode = mode;
},
+ showPicture() {
+ if (this.responseResult.contentType && this.contentType.includes(this.responseResult.contentType)) {
+ this.modes.push('picture')
+ this.srcUrl = 'data:' + this.responseResult.contentType + ';base64,' + this.responseResult.imageUrl;
+ }
+ },
setBodyType() {
if (
this.response &&
@@ -206,6 +223,7 @@ export default {
mounted() {
this.setBodyType();
this.setReqMessage();
+ this.showPicture();
},
computed: {
isSqlType() {
@@ -220,6 +238,9 @@ export default {
responseResult() {
return this.response && this.response.responseResult ? this.response.responseResult : {};
},
+ isPicture() {
+ return this.responseResult.contentType && this.contentType.includes(this.responseResult.contentType) && this.mode === 'picture';
+ },
},
};
diff --git a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/ResponseResult.java b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/ResponseResult.java
index 6b4ea3f1d8..ce4a03eec9 100644
--- a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/ResponseResult.java
+++ b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/ResponseResult.java
@@ -27,6 +27,10 @@ public class ResponseResult {
private String console;
+ private String contentType;
+
+ private byte[] imageUrl;
+
private final List assertions = new ArrayList<>();
}
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 c985b3de24..1c65fa0440 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
@@ -19,10 +19,7 @@ import org.apache.jmeter.visualizers.backend.BackendListener;
import org.apache.jorphan.collections.HashTree;
import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class JMeterBase {
private final static String THREAD_SPLIT = " ";
@@ -30,6 +27,8 @@ public class JMeterBase {
private final static String SPLIT_EQ = "split==";
private final static String SPLIT_AND = "split&&";
+ private static final List imageList = Arrays.asList("image/png", "image/jpeg", "image/gif", "image/bmp", "image/webp", "image/svg+xml", "image/apng", "image/avif");
+
public static HashTree getHashTree(Object scriptWrapper) throws Exception {
Field field = scriptWrapper.getClass().getDeclaredField("testPlan");
field.setAccessible(true);
@@ -105,6 +104,11 @@ public class JMeterBase {
&& result.getResponseDataAsString().length() > size) {
requestResult.setBody("");
} else {
+ //判断返回的类型是否是图片
+ if (StringUtils.isNotEmpty(result.getContentType()) && imageList.contains(result.getContentType())) {
+ responseResult.setContentType(result.getContentType());
+ responseResult.setImageUrl(result.getResponseData());
+ }
responseResult.setBody(result.getResponseDataAsString());
}
responseResult.setHeaders(result.getResponseHeaders());