Exemplo n.º 1
0
        public void GetHeaders(HeaderCb cb)
        {
            String name  = "";
            String value = "";
            bool   done  = false;

            using (StringReader reader = new StringReader(GetString()))
            {
                String line = "";
                while (done == false && (line = reader.ReadLine()) != null)
                {
                    Match m = Regex.Match(line, "^([^\t :]+):(.*)$");
                    // matched header: field
                    if (m.Success)
                    {
                        // call with last consumed header/value. new header means all (if any) values with FWS are consumed
                        if (name != "")
                        {
                            done = cb(name, value);
                        }

                        name  = m.Groups[1].Value.ToLower();
                        value = m.Groups[2].Value.TrimStart(' ');
                    }
                    // must be FWS
                    else if (name != "")
                    {
                        value += " " + line.TrimStart(' ');
                    }
                }
            }

            if (name != "" && done == false)
            {
                cb(name, value);
            }
        }
Exemplo n.º 2
0
        public void GetHeaders(HeaderCb cb)
        {
            String name = "";
            String value = "";
            bool done = false;

            using (StringReader reader = new StringReader(GetString()))
            {
                String line = "";
                while (done == false && (line = reader.ReadLine()) != null)
                {
                    Match m = Regex.Match(line, "^([^\t :]+):(.*)$");
                    // matched header: field
                    if (m.Success)
                    {
                        // call with last consumed header/value. new header means all (if any) values with FWS are consumed
                        if (name != "")
                            done = cb(name, value);
          
                        name = m.Groups[1].Value.ToLower();
                        value = m.Groups[2].Value.TrimStart(' ');
                    }
                    // must be FWS
                    else if (name != "")
                    {
                        value += " " + line.TrimStart(' ');
                    }
                }
            }

            if (name != "" && done == false)
                cb(name, value);
        }