Exemplo n.º 1
0
        public Boolean TryGetValue(String key, out MimeHeader value)
        {
            var header = _Headers.Find(el => String.Equals(el.Key, key, StringComparison.OrdinalIgnoreCase));

            value = header;
            return(header != null);
        }
Exemplo n.º 2
0
        private unsafe MimeHeader ParseHeader(MimeHeaderBufferByteArray headerPointer)
        {
            MimeHeader header = null;

            fixed(Byte *headerPtr = headerPointer.Data)
            {
                Byte *current = headerPtr;
                Byte *end     = headerPtr + headerPointer.Length * sizeof(Byte);

                while (*current == (Byte)' ')
                {
                    current++;
                }
                Byte *start = current;

                while (*current != (Byte)':')
                {
                    current++;
                    if (current == end)
                    {
                        var line = Encoding.UTF8.GetString(headerPointer.ToArray());
                        throw new InvalidMimeFormatException(line);
                    }
                }
                String key = this.Encoding.GetString(CreateNewBytes(new IntPtr(start), current - start));

                switch (key.ToLower())
                {
                case "content-type": header = new ContentType(); break;

                case "content-disposition": header = new ContentDisposition(); break;

                default: header = new MimeHeader(); break;
                }
                header.Key = key;

                current++;

                while (*current == (Byte)' ')
                {
                    current++;
                }
                header.RawValue = this.Encoding.GetString(CreateNewBytes(new IntPtr(current), end - current));

                if (header.HasParameter == false)
                {
                    header.Value = _Rfc2047Converter.Decode(current, end);
                }
                header.RawData = headerPointer.ToArray();
                ParseContentType(header as ContentType);
                ParseContentDisposition(header as ContentDisposition);
            }

            return(header);
        }
Exemplo n.º 3
0
 public Boolean TryGetValue(String key, out MimeHeader value)
 {
     var header = _Headers.Find(el => String.Equals(el.Key, key, StringComparison.OrdinalIgnoreCase));
     value = header;
     return header != null;
 }
Exemplo n.º 4
0
 public void Add(MimeHeader header)
 {
     _Headers.Add(header);
 }
Exemplo n.º 5
0
 public void Add(MimeHeader header)
 {
     _Headers.Add(header);
 }