From 76409e31b700733428daedffa91e3f9b1facf6f0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 29 Mar 2022 17:14:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dquery=E5=8F=82=E6=95=B0=E6=9C=AA=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5=E5=88=B0url=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1011784 --user=赵勇 【接口测试】场景-自定义请求,使用变量作为域名的时候,query参数拼不上 https://www.tapd.cn/55049933/s/1127331 --- .../request/sampler/MsHTTPSamplerProxy.java | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) 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 20d62d6049..755ba299f3 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 @@ -466,12 +466,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setProperty("HTTPSampler.path", envPath); } if (CollectionUtils.isNotEmpty(this.getArguments())) { - String path = envPath; - if (StringUtils.equalsIgnoreCase(this.getMethod(), "GET")) { - getQueryParameters(sampler); - } else { - path = postQueryParameters(envPath); - } + String path = postQueryParameters(envPath); if (HTTPConstants.DELETE.equals(this.getMethod()) && !path.startsWith("${")) { if (!path.startsWith("/")) { path = "/" + path; @@ -692,28 +687,28 @@ public class MsHTTPSamplerProxy extends MsTestElement { list.stream(). filter(KeyValue::isValid). filter(KeyValue::isEnable).forEach(keyValue -> { - try { - String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue(); - HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value); - if (keyValue.getValue() == null) { - httpArgument.setValue(""); - } - httpArgument.setAlwaysEncoded(keyValue.isUrlEncode()); - if (StringUtils.isNotBlank(keyValue.getContentType())) { - httpArgument.setContentType(keyValue.getContentType()); - } - if (StringUtils.equalsIgnoreCase(this.method, "get")) { - if (StringUtils.isNotEmpty(httpArgument.getValue())) { - arguments.addArgument(httpArgument); - } - } else { - arguments.addArgument(httpArgument); - } - } catch (Exception e) { - - } + try { + String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue(); + HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value); + if (keyValue.getValue() == null) { + httpArgument.setValue(""); } - ); + httpArgument.setAlwaysEncoded(keyValue.isUrlEncode()); + if (StringUtils.isNotBlank(keyValue.getContentType())) { + httpArgument.setContentType(keyValue.getContentType()); + } + if (StringUtils.equalsIgnoreCase(this.method, "get")) { + if (StringUtils.isNotEmpty(httpArgument.getValue())) { + arguments.addArgument(httpArgument); + } + } else { + arguments.addArgument(httpArgument); + } + } catch (Exception e) { + + } + } + ); return arguments; }