示例#1
0
        public MimeHeader(string name, string @value, MimeFormat format, MimeEncodingMethod encoding, Encoding charset)
        {
            if (name == null)
            throw new ArgumentNullException("name");
              else if (name.Length == 0)
            throw new ArgumentException("length of name is zero", "name");

              // TODO: check name
              // field-name  =  1*<any CHAR, excluding CTLs, SPACE, and ":">
              this.name = name;
              this.Index = 0;
              this.Format = format;
              this.Value = @value;
              this.Encoding = encoding;
              this.Charset = charset;
        }
示例#2
0
        public void SetValue(MimeFormat format, IEnumerable<MimeHeaderFragment> headerFragments)
        {
            if (headerFragments == null)
            throw new ArgumentNullException("headerFragments");

              Format = format;
              Encoding = MimeEncodingMethod.None;
              Charset  = null;
              Value = EncodeFragments(headerFragments);
        }
示例#3
0
 public MimeHeader(string name, string @value, MimeFormat format, MimeEncodingMethod encoding)
     : this(name, @value, format, encoding, null)
 {
 }
示例#4
0
        public static MimeHeader CreateContentType(MimeFormat format, MimeType mimeType, Encoding charset, string boundary, string name)
        {
            const string headerName = "Content-Type";

              if (mimeType == null)
            throw new ArgumentNullException("mimeType");

              var fragments = new List<MimeHeaderFragment>();

              fragments.Add(new MimeHeaderFragment(mimeType.ToString()));

              if (charset != null)
            fragments.Add(new MimeHeaderParameterFragment("charset", Charsets.ToString(charset)));

              if (boundary != null)
            fragments.Add(new MimeHeaderParameterFragment("boundary", boundary));

              if (name != null)
            // TODO: name*n*
            fragments.Add(new MimeHeaderParameterFragment("name", MimeEncoding.Encode(name, MimeEncodingMethod.Base64, Charsets.UTF8)));

              return new MimeHeader(headerName, format, fragments);
        }
示例#5
0
 public static MimeHeader CreateContentType(MimeFormat format, MimeType mimeType, Encoding charset, string boundary)
 {
     return CreateContentType(format, mimeType, charset, boundary, null);
 }
示例#6
0
 public static MimeHeader CreateContentType(MimeFormat format, MimeType mimeType, Encoding charset)
 {
     return CreateContentType(format, mimeType, charset, null, null);
 }
示例#7
0
 public static MimeHeader CreateContentTransferEncoding(MimeFormat format, ContentTransferEncodingMethod transferEncoding)
 {
     return new MimeHeader(ContentTransferEncoding.HeaderName,
                     format,
                     new[] {new MimeHeaderFragment(ContentTransferEncoding.GetEncodingName(transferEncoding))});
 }
示例#8
0
 public MimeHeader(string name, MimeFormat format, IEnumerable<MimeHeaderFragment> headerFragments)
     : this(name, string.Empty, format, MimeEncodingMethod.None, null)
 {
     SetValue(format, headerFragments);
 }