fix(接口测试): get请求无法追加url参数

This commit is contained in:
chenjianxing 2020-11-03 17:13:56 +08:00
parent 7e9afdac38
commit 021fef4980
1 changed files with 3 additions and 2 deletions

View File

@ -1001,7 +1001,8 @@ class JMXHttpRequest {
this.domain = environment.config.httpConfig.domain; this.domain = environment.config.httpConfig.domain;
this.port = environment.config.httpConfig.port; this.port = environment.config.httpConfig.port;
this.protocol = environment.config.httpConfig.protocol; this.protocol = environment.config.httpConfig.protocol;
let envPath = environment.config.httpConfig.protocol + "://" + environment.config.httpConfig.socket; let url = new URL(environment.config.httpConfig.protocol + "://" + environment.config.httpConfig.socket);
let envPath = url.pathname === '/' ? '' : url.pathname;
this.path = this.getPostQueryParameters(request, decodeURIComponent(envPath + (request.path ? request.path : ''))); this.path = this.getPostQueryParameters(request, decodeURIComponent(envPath + (request.path ? request.path : '')));
} }
this.connectTimeout = request.connectTimeout; this.connectTimeout = request.connectTimeout;
@ -1397,11 +1398,11 @@ class JMXGenerator {
body = this.filterKV(request.body.kvs); body = this.filterKV(request.body.kvs);
this.addRequestBodyFile(httpSamplerProxy, request, testId); this.addRequestBodyFile(httpSamplerProxy, request, testId);
} else { } else {
httpSamplerProxy.boolProp('HTTPSampler.postBodyRaw', true);
body.push({name: '', value: request.body.raw, encode: false, enable: true}); body.push({name: '', value: request.body.raw, encode: false, enable: true});
} }
if (request.method !== 'GET') { if (request.method !== 'GET') {
httpSamplerProxy.boolProp('HTTPSampler.postBodyRaw', true);
httpSamplerProxy.add(new HTTPSamplerArguments(body)); httpSamplerProxy.add(new HTTPSamplerArguments(body));
} }
} }