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); } } }
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 the_text_is_not_decoded_if_the_encoding_is_unknown() { Rfc2047Encoding.DecodeTextToken(UNKNOWN_ENCODING).ShouldBe(UNKNOWN_ENCODING); }
public void the_text_is_not_decoded_if_the_charset_is_unknown() { Rfc2047Encoding.DecodeTextToken(KLINGON).ShouldBe(KLINGON); }
public void the_decoding_is_done_including_spaces() { Rfc2047Encoding.DecodeTextToken(US_ASCII) .ShouldBe("Keith Moore <*****@*****.**>"); }
public void mutliple_encodings_are_supported() { Rfc2047Encoding.DecodeTextToken(ISO_SUBJECT).ShouldBe("If you can read this you understand the example."); }
public void encoded_characters_are_decoded() { Rfc2047Encoding.DecodeTextToken(ISO).ShouldBe("Keld Jørn Simonsen"); }