From e06e93d4844df7399efda415c482103835f936c5 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 24 Aug 2022 16:03:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5JMX=E7=9A=84=E5=9C=BA?= =?UTF-8?q?=E6=99=AFDELETE=E8=AF=B7=E6=B1=82=E5=A4=84=E7=90=86=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1016235 --user=王孝刚 【接口测试】导入JMX的场景,DELETE请求处理问题 https://www.tapd.cn/55049933/s/1232429 --- .../request/sampler/MsHTTPSamplerProxy.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 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 40a28ec10e..d8e676db68 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 @@ -49,6 +49,7 @@ import org.apache.jmeter.save.SaveService; import org.apache.jmeter.testelement.TestElement; import org.apache.jorphan.collections.HashTree; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLDecoder; import java.net.URLEncoder; @@ -405,7 +406,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) { sampler.setProperty("HTTPSampler.port", this.getPort()); - } else { + } else if (urlObject.getPort() != -1) { sampler.setPort(urlObject.getPort()); } sampler.setProtocol(urlObject.getProtocol()); @@ -457,12 +458,6 @@ public class MsHTTPSamplerProxy extends MsTestElement { if (!path.startsWith("/")) { path = "/" + path; } - String port = sampler.getPort() != 80 ? ":" + sampler.getPort() : ""; - if (StringUtils.equals("https", sampler.getProtocol()) && sampler.getPort() == 443) { - // 解决https delete请求时,path路径带443端口,请求头的host会变成域名加443 - port = ""; - } - path = sampler.getProtocol() + "://" + sampler.getDomain() + port + path; } sampler.setProperty("HTTPSampler.path", path); } @@ -481,7 +476,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8")); if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) { sampler.setProperty("HTTPSampler.port", this.getPort()); - } else { + } else if (urlObject.getPort() != -1) { sampler.setPort(urlObject.getPort()); } sampler.setProtocol(urlObject.getProtocol());