fix(接口测试): 修复post请求未拼接path的缺陷

--bug=1027640 --user=王孝刚 【接口测试】接口定义-post请求报错不支持
https://www.tapd.cn/55049933/s/1390715
This commit is contained in:
wxg0103 2023-07-10 11:48:00 +08:00 committed by fit2-zhao
parent 1c73fe6b32
commit 01e4cacb2b
1 changed files with 6 additions and 5 deletions

View File

@ -428,12 +428,16 @@ public class MsHTTPSamplerProxy extends MsTestElement {
try {
URL urlObject = new URL(url);
if (StringUtils.isNotBlank(this.getPath())) {
envPath += this.getPath();
envPath = this.getPath().startsWith("/") ? this.getPath() : StringUtils.join("/", this.getPath());
}
if (httpConfig.getSocket().contains("${")) {
envPath = StringUtils.isNotBlank(this.path) ? StringUtils.join(url, this.path) : url;
} else if (StringUtils.isNotEmpty(urlObject.getHost())) {
envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile();
if (StringUtils.isNotBlank(urlObject.getPath()) && urlObject.getPath().endsWith("/")) {
envPath = StringUtils.join(urlObject.getPath().substring(0, urlObject.getPath().length() - 1), envPath);
} else {
envPath = StringUtils.join(urlObject.getPath(), envPath);
}
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
sampler.setProtocol(httpConfig.getProtocol());
sampler.setPort(urlObject.getPort());
@ -451,9 +455,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
sampler.setProtocol(urlObject.getProtocol());
}
/*if (StringUtils.isNotEmpty(envPath) && !envPath.startsWith("/")) {
envPath = "/" + envPath;
}*/
sampler.setProperty("HTTPSampler.path", URLDecoder.decode(URLEncoder.encode(envPath, StandardCharsets.UTF_8.name()), StandardCharsets.UTF_8.name()));
}
}