fix(接口定义): #1006253 全局请求头与局部请求头去重

【全局请求头与局部请求头去重】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006253
This commit is contained in:
song-tianyang 2021-08-27 18:20:27 +08:00 committed by 刘瑞斌
parent cd08808fcc
commit f9eae5ce44
1 changed files with 16 additions and 1 deletions

View File

@ -650,7 +650,22 @@ public class MsHTTPSamplerProxy extends MsTestElement {
// header 也支持 mock 参数 // header 也支持 mock 参数
List<KeyValue> keyValues = headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).collect(Collectors.toList()); List<KeyValue> keyValues = headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).collect(Collectors.toList());
for (KeyValue keyValue : keyValues) { for (KeyValue keyValue : keyValues) {
headerManager.add(new Header(keyValue.getName(), ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()))); boolean hasHead = false;
//检查是否已经有重名的Head如果Header重复会导致执行报错
if(headerManager.getHeaders() != null){
for(int i = 0; i < headerManager.getHeaders().size(); i ++){
Header header = headerManager.getHeader(i);
String headName = header.getName();
if(StringUtils.equals(headName,keyValue.getName())){
hasHead = true;
break;
}
}
}
if(!hasHead){
headerManager.add(new Header(keyValue.getName(), ScriptEngineUtils.buildFunctionCallString(keyValue.getValue())));
}
} }
if (headerManager.getHeaders().size() > 0 && isAdd) { if (headerManager.getHeaders().size() > 0 && isAdd) {
tree.add(headerManager); tree.add(headerManager);