refactor(接口测试): 请求体选择的请求格式以请求头填写优先

This commit is contained in:
chenjianxing 2020-10-30 14:37:00 +08:00
parent 713257c4d5
commit d1fc4b4cdd
1 changed files with 6 additions and 2 deletions

View File

@ -1363,16 +1363,20 @@ class JMXGenerator {
} }
addContentType(request, type) { addContentType(request, type) {
let hasContentType = false;
for (let index in request.headers) { for (let index in request.headers) {
if (request.headers.hasOwnProperty(index)) { if (request.headers.hasOwnProperty(index)) {
if (request.headers[index].name === 'Content-Type') { if (request.headers[index].name === 'Content-Type' && request.headers[index].enable != false) {
request.headers.splice(index, 1); request.headers.splice(index, 1);
hasContentType = true;
break; break;
} }
} }
} }
if (!hasContentType) {
request.headers.push(new KeyValue({name: 'Content-Type', value: type})); request.headers.push(new KeyValue({name: 'Content-Type', value: type}));
} }
}
addRequestArguments(httpSamplerProxy, request) { addRequestArguments(httpSamplerProxy, request) {
let args = this.filterKV(request.parameters); let args = this.filterKV(request.parameters);