public ContentDispositionHeader(string header)
        {
            var fragments = header.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (fragments.Length == 0)
            {
                throw new FormatException("The header value {0} is invalid for Content-Disposition.".With(header));
            }
            Disposition = fragments[0].Trim();

            for (int i = 1; i < fragments.Length; i++)
            {
                var parameter = ParseParameter(fragments[i]);
                if (string.Compare(parameter.Key, "filename", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    FileName = parameter.Value;
                }
                else if (string.Compare(parameter.Key, "name", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Name = Rfc2047Encoding.DecodeTextToken(parameter.Value);
                }
            }
        }
Beispiel #2
0
        public ContentDispositionHeader(string header)
        {
            var fragments = SplitReg.Split(header).Where(f => !string.IsNullOrEmpty(f)).ToArray();

            if (fragments.Length == 0)
            {
                throw new FormatException("The header value {0} is invalid for Content-Disposition.".With(header));
            }
            Disposition = fragments[0].Trim();

            for (int i = 1; i < fragments.Length; i++)
            {
                var parameter = ParseParameter(fragments[i]);
                if (string.Compare(parameter.Key, "filename", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    FileName = parameter.Value;
                }
                else if (string.Compare(parameter.Key, "name", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Name = Rfc2047Encoding.DecodeTextToken(parameter.Value);
                }
            }
        }
 public void Add(Rfc2047Encoding encoding, Encoding charset, Byte[] value)
 {
     this.Encoding = encoding;
     this.Charset  = charset;
     _ByteList.Add(value);
 }
 public UserAgentEncoder(IUserAgent userAgent)
 {
     this._userAgent = Rfc2047Encoding.Rfc2047Encode(userAgent.Name.Trim().Replace(' ', '_')) + "/" + Rfc2047Encoding.Rfc2047Encode(userAgent.Version.Trim().Replace(' ', '_'));
 }
Beispiel #5
0
 public void the_text_is_not_decoded_if_the_encoding_is_unknown()
 {
     Rfc2047Encoding.DecodeTextToken(UNKNOWN_ENCODING).ShouldBe(UNKNOWN_ENCODING);
 }
Beispiel #6
0
 public void the_text_is_not_decoded_if_the_charset_is_unknown()
 {
     Rfc2047Encoding.DecodeTextToken(KLINGON).ShouldBe(KLINGON);
 }
Beispiel #7
0
 public void the_decoding_is_done_including_spaces()
 {
     Rfc2047Encoding.DecodeTextToken(US_ASCII)
     .ShouldBe("Keith Moore <*****@*****.**>");
 }
Beispiel #8
0
 public void mutliple_encodings_are_supported()
 {
     Rfc2047Encoding.DecodeTextToken(ISO_SUBJECT).ShouldBe("If you can read this you understand the example.");
 }
Beispiel #9
0
 public void encoded_characters_are_decoded()
 {
     Rfc2047Encoding.DecodeTextToken(ISO).ShouldBe("Keld Jørn Simonsen");
 }