示例#1
0
        private bool Parse()
        {
            bool error = false;

            if (this._headers.Count > 0)
            {
                return(!error);
            }
            System.String line = System.String.Empty;
            this._message.SeekPoint(this._startpoint);
            this._message.Encoding = default_encoding;
            for (line = _message.ReadUnfoldedLine(); line != null; line = _message.ReadUnfoldedLine())
            {
                if (line.Length == 0)
                {
                    this._endpoint    = this._message.Position_preRead;
                    this.BodyPosition = this._message.Position;
                    this._message.ReadLine_Undo(line);
                    break;
                }
                String [] headerline = line.Split(new Char[] { ':' }, 2);
                if (headerline.Length == 2)
                {
                    headerline[1] = headerline[1].TrimStart(new Char[] { ' ' });
                    if (this._headers.Contains(headerline[0]))
                    {
                        this._headers[headerline[0]] = System.String.Concat(this._headers[headerline[0]], "\r\n", headerline[1]);
                    }
                    else
                    {
                        this._headers.Add(headerline[0].ToLower(), headerline[1]);
                    }
                }
            }
            this.mt = new HeaderInfo(this._headers);
            return(!error);
        }