Beispiel #1
0
        private long ParseHeader(string[] lines)
        {
            int  numberOfLines = lines.Length;
            long bodyStart     = 0;

            for (int i = 0; i < numberOfLines; i++)
            {
                string currentLine = lines[i].Replace("\n", "");

                int lineType = GetHeaderLineType(currentLine);

                switch (lineType)
                {
                // From:
                case m_fromState:
                    m_from = Pop3Parse.From(currentLine);
                    break;

                // Subject:
                case m_subjectState:
                    m_subject = Pop3Parse.Subject(currentLine);
                    break;

                // To:
                case m_toState:
                    m_to = Pop3Parse.To(currentLine);
                    break;

                // Content-Type
                case m_contentTypeState:

                    m_contentType =
                        Pop3Parse.ContentType(currentLine);

                    m_isMultipart =
                        Pop3Parse.IsMultipart(m_contentType);

                    if (m_isMultipart)
                    {
                        // if boundary definition is on next
                        // line ...

                        if (m_contentType
                            .Substring(m_contentType.Length - 1, 1).
                            Equals(";"))
                        {
                            ++i;

                            m_multipartBoundary
                                = Pop3Parse.
                                  MultipartBoundary(lines[i].
                                                    Replace("\n", ""));
                        }
                        else
                        {
                            // boundary definition is on same
                            // line as "Content-Type" ...

                            m_multipartBoundary =
                                Pop3Parse
                                .MultipartBoundary(m_contentType);
                        }
                    }

                    break;

                case m_endOfHeader:
                    bodyStart = i + 1;
                    break;
                }

                if (bodyStart > 0)
                {
                    break;
                }
            }

            return(bodyStart);
        }