From 56d0a24fd8d78de295ed90ece30343b2d48ce528 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 30 Dec 2020 16:55:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E9=80=9A=E7=94=A8=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsScenario.java | 6 ------ .../api/dto/definition/request/MsTestElement.java | 10 ---------- .../request/sampler/MsHTTPSamplerProxy.java | 12 +++++++++--- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index ae76ff73db..19097a14bf 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -109,12 +109,6 @@ public class MsScenario extends MsTestElement { arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); } - if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null - && CollectionUtils.isNotEmpty(config.getConfig().getHttpConfig().getHeaders())) { - config.getConfig().getHttpConfig().getHeaders().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> - arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") - ); - } return arguments; } } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index b54ffdff16..54f8dc608e 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -149,16 +149,6 @@ public abstract class MsTestElement { arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); } - if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null - && CollectionUtils.isNotEmpty(config.getConfig().getHttpConfig().getHeaders())) { - arguments.setEnabled(true); - arguments.setName(name + "Variables"); - arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName()); - arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel")); - config.getConfig().getHttpConfig().getHeaders().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> - arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") - ); - } return arguments; } } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index cc4947e9ff..2c3b7d0f98 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -189,9 +189,15 @@ public class MsHTTPSamplerProxy extends MsTestElement { } final HashTree httpSamplerTree = tree.add(sampler); - if (CollectionUtils.isNotEmpty(this.headers)) { - setHeader(httpSamplerTree); + // 通用请求Headers + if (config != null && config.getConfig() != null && config.getConfig().getHttpConfig() != null + && CollectionUtils.isNotEmpty(config.getConfig().getHttpConfig().getHeaders())) { + setHeader(httpSamplerTree, config.getConfig().getHttpConfig().getHeaders()); } + if (CollectionUtils.isNotEmpty(this.headers)) { + setHeader(httpSamplerTree, this.headers); + } + //判断是否要开启DNS if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null && config.getConfig().getCommonConfig().isEnableHost()) { @@ -266,7 +272,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { return arguments; } - public void setHeader(HashTree tree) { + public void setHeader(HashTree tree, List headers) { HeaderManager headerManager = new HeaderManager(); headerManager.setEnabled(true); headerManager.setName(this.getName() + "Headers");