SIPSorcery.SIP.App.SIPCallDescriptor.ParseCustomHeaders C# (CSharp) Method

ParseCustomHeaders() public static method

public static ParseCustomHeaders ( string customHeaders ) : List
customHeaders string
return List
        public static List<string> ParseCustomHeaders(string customHeaders)
        {
            List<string> customHeaderList = new List<string>();

            try
            {
                if (!customHeaders.IsNullOrBlank())
                {
                    string[] customerHeadersList = customHeaders.Split(m_customHeadersSeparator);

                    if (customerHeadersList != null && customerHeadersList.Length > 0)
                    {
                        foreach (string customHeader in customerHeadersList)
                        {
                            if (customHeader.IsNullOrBlank())
                            {
                                continue;
                            }
                            else if (customHeader.IndexOf(':') == -1)
                            {
                                logger.Warn("ParseCustomHeaders skipping custom header due to missing colon, " + customHeader + ".");
                                continue;
                            }
                            else
                            {
                                //int colonIndex = customHeader.IndexOf(':');
                                //string headerName = customHeader.Substring(0, colonIndex).Trim();
                                //string headerValue = (customHeader.Length > colonIndex) ? customHeader.Substring(colonIndex + 1).Trim() : String.Empty;

                                if (Regex.Match(customHeader.Trim(), "^(Via|From|To|Contact|CSeq|Call-ID|Max-Forwards|Content-Length)$", RegexOptions.IgnoreCase).Success)
                                {
                                    logger.Warn("ParseCustomHeaders skipping custom header due to an non-permitted string in header name, " + customHeader + ".");
                                    continue;
                                }
                                else
                                {
                                    customHeaderList.Add(customHeader.Trim());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception ParseCustomHeaders (" + customHeaders + "). " + excp.Message);
            }

            return customHeaderList;
        }