fix(接口测试): 修复自定义请求变量缺失的缺陷

--bug=1019069 --user=王孝刚 【接口测试】github#19227,脚本中设置url变量,在请定义请求时,变量值会缺失 https://www.tapd.cn/55049933/s/1288741
This commit is contained in:
wxg0103 2022-11-04 12:14:06 +08:00 committed by wxg0103
parent e0360ffb8d
commit f23191536d
1 changed files with 0 additions and 10 deletions

View File

@ -427,22 +427,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
}
} else {
String url = this.getUrl();
if (StringUtils.isNotEmpty(url) && !url.startsWith("http://") && !url.startsWith("https://")) {
url = "http://" + url;
}
if (StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
url = url.replace(this.getPort(), "10990");
}
if (StringUtils.isEmpty(url)) {
MSException.throwException("请重新选择环境");
}
URL urlObject = new URL(url);
if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
sampler.setProperty("HTTPSampler.port", this.getPort());
} else if (urlObject.getPort() != -1) {
sampler.setPort(urlObject.getPort());
}
sampler.setProtocol(urlObject.getProtocol());
String envPath = url;
sampler.setProperty("HTTPSampler.path", envPath, StandardCharsets.UTF_8.name());
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {