Source:
<code><START> private void addHeadersToMessage(SipServletRequest message, Map<String, ArrayList<String> > headers) { <END> if(headers!=null) { for (Map.Entry<String, ArrayList<String>> entry : headers.entrySet()) { String headerName = entry.getKey(); StringBuilder sb = new StringBuilder(); if(entry.getValue() instanceof ArrayList){ for(String pair : entry.getValue()){ sb.append(";").append(pair); } } if(logger.isDebugEnabled()) { logger.debug("headerName="+headerName+" headerVal="+message.getHeader(headerName)+" concatValue="+sb.toString()); } if(!headerName.equalsIgnoreCase("Request-URI")){ String headerVal = message.getHeader(headerName); if(headerVal!=null && !headerVal.isEmpty()) { message.setHeader(headerName , headerVal+sb.toString()); }else{ message.addHeader(headerName , sb.toString()); } }else{ javax.servlet.sip.URI reqURI = message.getRequestURI(); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); } for(String keyValPair :entry.getValue()){ String parName = ""; String parVal = ""; int equalsPos = keyValPair.indexOf("="); parName = keyValPair.substring(0, equalsPos); parVal = keyValPair.substring(equalsPos+1); reqURI.setParameter(parName, parVal); if(logger.isDebugEnabled()) { logger.debug("ReqURI pars ="+parName+"="+parVal+" equalsPos="+equalsPos+" keyValPair="+keyValPair); } } message.setRequestURI(reqURI); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); } } if(logger.isDebugEnabled()) { logger.debug("headerName="+headerName+" headerVal="+message.getHeader(headerName)); } } } }</code><technical_language>@abdulazizali77 apply more strict rules headers added. check if header is RURI a custom headers (starting X-). @deruelle @scottbarstow do allow more that</technical_language>

Target:
private void addHeadersToMessage(SipServletRequest message, Map<String, ArrayList<String> > headers) { if(headers!=null) { for (Map.Entry<String, ArrayList<String>> entry : headers.entrySet()) { String headerName = entry.getKey(); StringBuilder sb = new StringBuilder(); if(entry.getValue() instanceof ArrayList){ for(String pair : entry.getValue()){ sb.append(";").append(pair); } } if(logger.isDebugEnabled()) { logger.debug("headerName="+headerName+" headerVal="+message.getHeader(headerName)+" concatValue="+sb.toString()); } if(!headerName.equalsIgnoreCase("Request-URI")){ try { String headerVal = message.getHeader(headerName); if(headerVal!=null && !headerVal.isEmpty()) { message.setHeader(headerName , headerVal+sb.toString()); }else{ message.addHeader(headerName , sb.toString()); } } catch (IllegalArgumentException iae) { if(logger.isErrorEnabled()) { logger.error("Exception while setting message header: "+iae.getMessage()); } } }else{ javax.servlet.sip.URI reqURI = message.getRequestURI(); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); } for(String keyValPair :entry.getValue()){ String parName = ""; String parVal = ""; int equalsPos = keyValPair.indexOf("="); parName = keyValPair.substring(0, equalsPos); parVal = keyValPair.substring(equalsPos+1); reqURI.setParameter(parName, parVal); if(logger.isDebugEnabled()) { logger.debug("ReqURI pars ="+parName+"="+parVal+" equalsPos="+equalsPos+" keyValPair="+keyValPair); } } message.setRequestURI(reqURI); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); } } if(logger.isDebugEnabled()) { logger.debug("headerName="+headerName+" headerVal="+message.getHeader(headerName)); } } } }