fix(接口测试): 修复post请求未拼接path的缺陷
--bug=1027640 --user=王孝刚 【接口测试】接口定义-post请求报错不支持 https://www.tapd.cn/55049933/s/1390715
This commit is contained in:
parent
1c73fe6b32
commit
01e4cacb2b
|
@ -428,12 +428,16 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
try {
|
try {
|
||||||
URL urlObject = new URL(url);
|
URL urlObject = new URL(url);
|
||||||
if (StringUtils.isNotBlank(this.getPath())) {
|
if (StringUtils.isNotBlank(this.getPath())) {
|
||||||
envPath += this.getPath();
|
envPath = this.getPath().startsWith("/") ? this.getPath() : StringUtils.join("/", this.getPath());
|
||||||
}
|
}
|
||||||
if (httpConfig.getSocket().contains("${")) {
|
if (httpConfig.getSocket().contains("${")) {
|
||||||
envPath = StringUtils.isNotBlank(this.path) ? StringUtils.join(url, this.path) : url;
|
envPath = StringUtils.isNotBlank(this.path) ? StringUtils.join(url, this.path) : url;
|
||||||
} else if (StringUtils.isNotEmpty(urlObject.getHost())) {
|
} 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.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
|
||||||
sampler.setProtocol(httpConfig.getProtocol());
|
sampler.setProtocol(httpConfig.getProtocol());
|
||||||
sampler.setPort(urlObject.getPort());
|
sampler.setPort(urlObject.getPort());
|
||||||
|
@ -451,9 +455,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
|
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
|
||||||
sampler.setProtocol(urlObject.getProtocol());
|
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()));
|
sampler.setProperty("HTTPSampler.path", URLDecoder.decode(URLEncoder.encode(envPath, StandardCharsets.UTF_8.name()), StandardCharsets.UTF_8.name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue