93 instantiations of ContentDispositionHeaderValue
Microsoft.AspNetCore.Http.Extensions.Tests (1)
HeaderDictionaryTypeExtensionsTest.cs (1)
63var expected = new ContentDispositionHeaderValue("form-data") { Name = "\"fieldName\"" };
Microsoft.AspNetCore.Http.Microbenchmarks (1)
ContentDispositionHeaderValueBenchmarks.cs (1)
11private readonly ContentDispositionHeaderValue _contentDisposition = new ContentDispositionHeaderValue("inline");
Microsoft.AspNetCore.Http.Results (1)
src\Shared\ResultsHelpers\FileResultHelper.cs (1)
352var contentDisposition = new ContentDispositionHeaderValue("attachment");
Microsoft.AspNetCore.Mvc.Core (1)
src\Shared\ResultsHelpers\FileResultHelper.cs (1)
352var contentDisposition = new ContentDispositionHeaderValue("attachment");
Microsoft.AspNetCore.Mvc.Core.Test (1)
FileResultHelperTest.cs (1)
213var cd = new ContentDispositionHeaderValue("attachment");
Microsoft.Net.Http.Headers (1)
ContentDispositionHeaderValue.cs (1)
295var contentDispositionHeader = new ContentDispositionHeaderValue();
Microsoft.Net.Http.Headers.Tests (87)
ContentDispositionHeaderValueTest.cs (87)
14Assert.Throws<ArgumentException>(() => new ContentDispositionHeaderValue(null)); 21Assert.Throws<ArgumentException>(() => new ContentDispositionHeaderValue(string.Empty)); 44var contentDisposition = new ContentDispositionHeaderValue("inline"); 58var contentDisposition = new ContentDispositionHeaderValue("inline"); 65var contentDisposition = new ContentDispositionHeaderValue("inline"); 75var contentDisposition = new ContentDispositionHeaderValue("inline"); 90var contentDisposition = new ContentDispositionHeaderValue("inline"); 110var contentDisposition = new ContentDispositionHeaderValue("inline"); 130var contentDisposition = new ContentDispositionHeaderValue("inline"); 145var contentDisposition = new ContentDispositionHeaderValue("inline"); 160var contentDisposition = new ContentDispositionHeaderValue("inline"); 182var contentDisposition = new ContentDispositionHeaderValue("inline"); 204var contentDisposition = new ContentDispositionHeaderValue("inline"); 219var contentDisposition = new ContentDispositionHeaderValue("inline"); 227var contentDisposition = new ContentDispositionHeaderValue("inline"); 235var contentDisposition = new ContentDispositionHeaderValue("inline"); 266var contentDisposition = new ContentDispositionHeaderValue("inline"); 295var contentDisposition = new ContentDispositionHeaderValue("inline"); 307var contentDisposition = new ContentDispositionHeaderValue("inline"); 333var contentDisposition = new ContentDispositionHeaderValue("inline"); 351var contentDisposition = new ContentDispositionHeaderValue("inline"); 372var contentDisposition = new ContentDispositionHeaderValue("inline"); 394var contentDisposition = new ContentDispositionHeaderValue("inline"); 432var contentDisposition1 = new ContentDispositionHeaderValue("inline"); 433var contentDisposition2 = new ContentDispositionHeaderValue("inline"); 435var contentDisposition3 = new ContentDispositionHeaderValue("inline"); 437var contentDisposition4 = new ContentDispositionHeaderValue("INLINE"); 438var contentDisposition5 = new ContentDispositionHeaderValue("INLINE"); 451var contentDisposition1 = new ContentDispositionHeaderValue("inline"); 452var contentDisposition2 = new ContentDispositionHeaderValue("inline"); 454var contentDisposition3 = new ContentDispositionHeaderValue("inline"); 456var contentDisposition4 = new ContentDispositionHeaderValue("INLINE"); 457var contentDisposition5 = new ContentDispositionHeaderValue("INLINE"); 459var contentDisposition6 = new ContentDispositionHeaderValue("INLINE"); 462var contentDisposition7 = new ContentDispositionHeaderValue("attachment"); 478var expected = new ContentDispositionHeaderValue("inline"); 514var expected = new ContentDispositionHeaderValue("inline"); 542{ "inline", new ContentDispositionHeaderValue("inline") }, // @"This should be equivalent to not including the header at all." 543{ "inline;", new ContentDispositionHeaderValue("inline") }, 544{ "inline;name=", new ContentDispositionHeaderValue("inline") { Parameters = { new NameValueHeaderValue("name", "") } } }, // TODO: passing in a null value causes a strange assert on CoreCLR before the test even starts. Not reproducible in the body of a test. 545{ "inline;name=value", new ContentDispositionHeaderValue("inline") { Name = "value" } }, 546{ "inline;name=value;", new ContentDispositionHeaderValue("inline") { Name = "value" } }, 547{ "inline;name=value;", new ContentDispositionHeaderValue("inline") { Name = "value" } }, 548{ @"inline; filename=""foo.html""", new ContentDispositionHeaderValue("inline") { FileName = @"""foo.html""" } }, 549{ @"inline; filename=""Not an attachment!""", new ContentDispositionHeaderValue("inline") { FileName = @"""Not an attachment!""" } }, // 'inline', specifying a filename of Not an attachment! - this checks for proper parsing for disposition types. 550{ @"inline; filename=""foo.pdf""", new ContentDispositionHeaderValue("inline") { FileName = @"""foo.pdf""" } }, 551{ "attachment", new ContentDispositionHeaderValue("attachment") }, 552{ "ATTACHMENT", new ContentDispositionHeaderValue("ATTACHMENT") }, 553{ @"attachment; filename=""foo.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo.html""" } }, 554{ @"attachment; filename=""\""quoting\"" tested.html""", new ContentDispositionHeaderValue("attachment") { FileName = "\"\"quoting\" tested.html\"" } }, // 'attachment', specifying a filename of \"quoting\" tested.html (using double quotes around "quoting" to test... quoting) 555{ @"attachment; filename=""Here's a semicolon;.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""Here's a semicolon;.html""" } }, // , 'attachment', specifying a filename of Here's a semicolon;.html - this checks for proper parsing for parameters. 556{ @"attachment; foo=""bar""; filename=""foo.html""", new ContentDispositionHeaderValue(@"attachment") { FileName = @"""foo.html""", Parameters = { new NameValueHeaderValue("foo", @"""bar""") } } }, // 'attachment', specifying a filename of foo.html and an extension parameter "foo" which should be ignored (see <a href="http://greenbytes.de/tech/webdav/rfc2183.html#rfc.section.2.8">Section 2.8 of RFC 2183</a>.). 557{ @"attachment; foo=""\""\\"";filename=""foo.html""", new ContentDispositionHeaderValue(@"attachment") { FileName = @"""foo.html""", Parameters = { new NameValueHeaderValue("foo", @"""\""\\""") } } }, // 'attachment', specifying a filename of foo.html and an extension parameter "foo" which should be ignored (see <a href="http://greenbytes.de/tech/webdav/rfc2183.html#rfc.section.2.8">Section 2.8 of RFC 2183</a>.). The extension parameter actually uses backslash-escapes. This tests whether the UA properly skips the parameter. 558{ @"attachment; FILENAME=""foo.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo.html""" } }, 559{ @"attachment; filename=foo.html", new ContentDispositionHeaderValue("attachment") { FileName = "foo.html" } }, // 'attachment', specifying a filename of foo.html using a token instead of a quoted-string. 560{ @"attachment; filename='foo.bar'", new ContentDispositionHeaderValue("attachment") { FileName = "'foo.bar'" } }, // 'attachment', specifying a filename of 'foo.bar' using single quotes. 561{ @"attachment; filename=""foo-ä.html""", new ContentDispositionHeaderValue("attachment" ) { Parameters = { new NameValueHeaderValue("filename", @"""foo-ä.html""") } } }, // 'attachment', specifying a filename of foo-ä.html, using plain ISO-8859-1 562{ @"attachment; filename=""foo-&#xc3;&#xa4;.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo-&#xc3;&#xa4;.html""" } }, // 'attachment', specifying a filename of foo-&#xc3;&#xa4;.html, which happens to be foo-ä.html using UTF-8 encoding. 563{ @"attachment; filename=""foo-%41.html""", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("filename", @"""foo-%41.html""") } } }, 564{ @"attachment; filename=""50%.html""", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("filename", @"""50%.html""") } } }, 565{ @"attachment; filename=""foo-%\41.html""", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("filename", @"""foo-%\41.html""") } } }, // 'attachment', specifying a filename of foo-%41.html, using an escape character (this tests whether adding an escape character inside a %xx sequence can be used to disable the non-conformant %xx-unescaping). 566{ @"attachment; name=""foo-%41.html""", new ContentDispositionHeaderValue("attachment") { Name = @"""foo-%41.html""" } }, // 'attachment', specifying a <i>name</i> parameter of foo-%41.html. (this test was added to observe the behavior of the (unspecified) treatment of ""name"" as synonym for ""filename""; see <a href=""http://www.imc.org/ietf-smtp/mail-archive/msg05023.html"">Ned Freed's summary</a> where this comes from in MIME messages) 567{ @"attachment; filename=""ä-%41.html""", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("filename", @"""ä-%41.html""") } } }, // 'attachment', specifying a filename parameter of ä-%41.html. (this test was added to observe the behavior when non-ASCII characters and percent-hexdig sequences are combined) 568{ @"attachment; filename=""foo-%c3%a4-%e2%82%ac.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo-%c3%a4-%e2%82%ac.html""" } }, // 'attachment', specifying a filename of foo-%c3%a4-%e2%82%ac.html, using raw percent encoded UTF-8 to represent foo-ä-&#x20ac;.html 569{ @"attachment; filename =""foo.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo.html""" } }, 570{ @"attachment; xfilename=foo.html", new ContentDispositionHeaderValue("attachment" ) { Parameters = { new NameValueHeaderValue("xfilename", "foo.html") } } }, 571{ @"attachment; filename=""/foo.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""/foo.html""" } }, 572{ @"attachment; creation-date=""Wed, 12 Feb 1997 16:29:51 -0500""", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("creation-date", @"""Wed, 12 Feb 1997 16:29:51 -0500""") } } }, 573{ @"attachment; modification-date=""Wed, 12 Feb 1997 16:29:51 -0500""", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("modification-date", @"""Wed, 12 Feb 1997 16:29:51 -0500""") } } }, 574{ @"foobar", new ContentDispositionHeaderValue("foobar") }, // @"This should be equivalent to using ""attachment""." 575{ @"attachment; example=""filename=example.txt""", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("example", @"""filename=example.txt""") } } }, 576{ @"attachment; filename*=iso-8859-1''foo-%E4.html", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("filename*", "iso-8859-1''foo-%E4.html") } } }, // 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded ISO-8859-1 577{ @"attachment; filename*=UTF-8''foo-%c3%a4-%e2%82%ac.html", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("filename*", "UTF-8''foo-%c3%a4-%e2%82%ac.html") } } }, // 'attachment', specifying a filename of foo-ä-&#x20ac;.html, using RFC2231 encoded UTF-8 578{ @"attachment; filename*=''foo-%c3%a4-%e2%82%ac.html", new ContentDispositionHeaderValue("attachment") { Parameters = { new NameValueHeaderValue("filename*", "''foo-%c3%a4-%e2%82%ac.html") } } }, // Behavior is undefined in RFC 2231, the charset part is missing, although UTF-8 was used. 579{ @"attachment; filename*=UTF-8''foo-a%22.html", new ContentDispositionHeaderValue("attachment") { FileNameStar = @"foo-a"".html" } }, 580{ @"attachment; filename*= UTF-8''foo-%c3%a4.html", new ContentDispositionHeaderValue("attachment") { FileNameStar = "foo-ä.html" } }, 581{ @"attachment; filename* =UTF-8''foo-%c3%a4.html", new ContentDispositionHeaderValue("attachment") { FileNameStar = "foo-ä.html" } }, 582{ @"attachment; filename*=UTF-8''A-%2541.html", new ContentDispositionHeaderValue("attachment") { FileNameStar = "A-%41.html" } }, 583{ @"attachment; filename*=UTF-8''%5cfoo.html", new ContentDispositionHeaderValue("attachment") { FileNameStar = @"\foo.html" } }, 584{ @"attachment; filename=""foo-ae.html""; filename*=UTF-8''foo-%c3%a4.html", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo-ae.html""", FileNameStar = "foo-ä.html" } }, 585{ @"attachment; filename*=UTF-8''foo-%c3%a4.html; filename=""foo-ae.html""", new ContentDispositionHeaderValue("attachment") { FileNameStar = "foo-ä.html", FileName = @"""foo-ae.html""" } }, 586{ @"attachment; foobar=x; filename=""foo.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo.html""", Parameters = { new NameValueHeaderValue("foobar", "x") } } }, 587{ @"attachment; filename=""=?ISO-8859-1?Q?foo-=E4.html?=""", new ContentDispositionHeaderValue("attachment") { FileName = @"""=?ISO-8859-1?Q?foo-=E4.html?=""" } }, // attachment; filename="=?ISO-8859-1?Q?foo-=E4.html?=" 588{ @"attachment; filename=""=?utf-8?B?Zm9vLeQuaHRtbA==?=""", new ContentDispositionHeaderValue("attachment") { FileName = @"""=?utf-8?B?Zm9vLeQuaHRtbA==?=""" } }, // attachment; filename="=?utf-8?B?Zm9vLeQuaHRtbA==?=" 589{ @"attachment; filename=foo.html ;", new ContentDispositionHeaderValue("attachment") { FileName="foo.html" } }, // 'attachment', specifying a filename of foo.html using a token instead of a quoted-string, and adding a trailing semicolon., 655var contentDisposition = new ContentDispositionHeaderValue("attachment"); 704Assert.Throws<FormatException>(() => new ContentDispositionHeaderValue(contentDisposition));
101 references to ContentDispositionHeaderValue
Microsoft.AspNetCore.HeaderParsing (5)
CommonHeaders.cs (1)
45public static HeaderSetup<ContentDispositionHeaderValue> ContentDisposition => new(HeaderNames.ContentDisposition, ContentDispositionHeaderValueParser.Instance, cacheable: true);
Parsers\ContentDispositionHeaderValueParser.cs (4)
10internal sealed class ContentDispositionHeaderValueParser : HeaderParser<ContentDispositionHeaderValue> 14public override bool TryParse(StringValues values, [NotNullWhen(true)] out ContentDispositionHeaderValue? result, [NotNullWhen(false)] out string? error) 16if (values.Count != 1 || !ContentDispositionHeaderValue.TryParse(values[0], out var parsedValue))
Microsoft.AspNetCore.HeaderParsing.Tests (3)
ParserTests.cs (3)
148Assert.True(ContentDispositionHeaderValueParser.Instance.TryParse(sv, out var result, out var error)); 158Assert.False(ContentDispositionHeaderValueParser.Instance.TryParse(sv, out var result, out var error)); 167Assert.False(ContentDispositionHeaderValueParser.Instance.TryParse(sv, out var result, out var error));
Microsoft.AspNetCore.Http (2)
Features\FormFeature.cs (2)
244if (!ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out var contentDisposition))
Microsoft.AspNetCore.Http.Extensions (8)
HeaderDictionaryTypeExtensions.cs (4)
137private static ContentDispositionHeaderValue? ParseCacheContentDispositionHeaderValue(string value) => ContentDispositionHeaderValue.TryParse(value, out var result) ? result : null; 184else if (typeof(T) == typeof(ContentDispositionHeaderValue))
RequestHeaders.cs (2)
109public ContentDispositionHeaderValue? ContentDisposition 113return Headers.Get<ContentDispositionHeaderValue>(HeaderNames.ContentDisposition);
ResponseHeaders.cs (2)
49public ContentDispositionHeaderValue? ContentDisposition 53return Headers.Get<ContentDispositionHeaderValue>(HeaderNames.ContentDisposition);
Microsoft.AspNetCore.Http.Extensions.Tests (3)
HeaderDictionaryTypeExtensionsTest.cs (3)
61var result = context.Request.GetTypedHeaders().Get<ContentDispositionHeaderValue>(HeaderNames.ContentDisposition); 63var expected = new ContentDispositionHeaderValue("form-data") { Name = "\"fieldName\"" };
Microsoft.AspNetCore.Http.Microbenchmarks (1)
ContentDispositionHeaderValueBenchmarks.cs (1)
11private readonly ContentDispositionHeaderValue _contentDisposition = new ContentDispositionHeaderValue("inline");
Microsoft.AspNetCore.Http.Results (1)
src\Shared\ResultsHelpers\FileResultHelper.cs (1)
352var contentDisposition = new ContentDispositionHeaderValue("attachment");
Microsoft.AspNetCore.Mvc.Core (1)
src\Shared\ResultsHelpers\FileResultHelper.cs (1)
352var contentDisposition = new ContentDispositionHeaderValue("attachment");
Microsoft.AspNetCore.Mvc.Core.Test (1)
FileResultHelperTest.cs (1)
213var cd = new ContentDispositionHeaderValue("attachment");
Microsoft.AspNetCore.WebUtilities (8)
FileMultipartSection.cs (2)
13private readonly ContentDispositionHeaderValue _contentDispositionHeader; 30public FileMultipartSection(MultipartSection section, ContentDispositionHeaderValue? header)
FormMultipartSection.cs (2)
13private readonly ContentDispositionHeaderValue _contentDispositionHeader; 30public FormMultipartSection(MultipartSection section, ContentDispositionHeaderValue? header)
MultipartSectionConverterExtensions.cs (4)
55/// <returns>A <see cref="ContentDispositionHeaderValue"/> if the header was found, null otherwise</returns> 56public static ContentDispositionHeaderValue? GetContentDispositionHeader(this MultipartSection section) 58if (!ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out var header))
Microsoft.Net.Http.Headers (15)
ContentDispositionHeaderValue.cs (12)
43private static readonly HttpHeaderParser<ContentDispositionHeaderValue> Parser 44= new GenericHeaderParser<ContentDispositionHeaderValue>(false, GetDispositionTypeLength); 56/// Initializes a new instance of <see cref="ContentDispositionHeaderValue"/>. 233var other = obj as ContentDispositionHeaderValue; 252/// Parses <paramref name="input"/> as a <see cref="ContentDispositionHeaderValue"/> value. 256public static ContentDispositionHeaderValue Parse(StringSegment input) 263/// Attempts to parse the specified <paramref name="input"/> as a <see cref="ContentDispositionHeaderValue"/>. 267/// <returns><see langword="true"/> if input is a valid <see cref="ContentDispositionHeaderValue"/>, otherwise <see langword="false"/>.</returns> 268public static bool TryParse(StringSegment input, [NotNullWhen(true)] out ContentDispositionHeaderValue? parsedValue) 274private static int GetDispositionTypeLength(StringSegment input, int startIndex, out ContentDispositionHeaderValue? parsedValue) 295var contentDispositionHeader = new ContentDispositionHeaderValue();
ContentDispositionHeaderValueIdentityExtensions.cs (3)
9/// Various extension methods for <see cref="ContentDispositionHeaderValue"/> for identifying the type of the disposition header 18public static bool IsFileDisposition(this ContentDispositionHeaderValue header) 31public static bool IsFormDisposition(this ContentDispositionHeaderValue header)
Microsoft.Net.Http.Headers.Tests (53)
ContentDispositionHeaderValueTest.cs (53)
44var contentDisposition = new ContentDispositionHeaderValue("inline"); 58var contentDisposition = new ContentDispositionHeaderValue("inline"); 65var contentDisposition = new ContentDispositionHeaderValue("inline"); 75var contentDisposition = new ContentDispositionHeaderValue("inline"); 90var contentDisposition = new ContentDispositionHeaderValue("inline"); 110var contentDisposition = new ContentDispositionHeaderValue("inline"); 130var contentDisposition = new ContentDispositionHeaderValue("inline"); 145var contentDisposition = new ContentDispositionHeaderValue("inline"); 160var contentDisposition = new ContentDispositionHeaderValue("inline"); 182var contentDisposition = new ContentDispositionHeaderValue("inline"); 204var contentDisposition = new ContentDispositionHeaderValue("inline"); 219var contentDisposition = new ContentDispositionHeaderValue("inline"); 227var contentDisposition = new ContentDispositionHeaderValue("inline"); 235var contentDisposition = new ContentDispositionHeaderValue("inline"); 266var contentDisposition = new ContentDispositionHeaderValue("inline"); 295var contentDisposition = new ContentDispositionHeaderValue("inline"); 307var contentDisposition = new ContentDispositionHeaderValue("inline"); 333var contentDisposition = new ContentDispositionHeaderValue("inline"); 351var contentDisposition = new ContentDispositionHeaderValue("inline"); 372var contentDisposition = new ContentDispositionHeaderValue("inline"); 394var contentDisposition = new ContentDispositionHeaderValue("inline"); 432var contentDisposition1 = new ContentDispositionHeaderValue("inline"); 433var contentDisposition2 = new ContentDispositionHeaderValue("inline"); 435var contentDisposition3 = new ContentDispositionHeaderValue("inline"); 437var contentDisposition4 = new ContentDispositionHeaderValue("INLINE"); 438var contentDisposition5 = new ContentDispositionHeaderValue("INLINE"); 451var contentDisposition1 = new ContentDispositionHeaderValue("inline"); 452var contentDisposition2 = new ContentDispositionHeaderValue("inline"); 454var contentDisposition3 = new ContentDispositionHeaderValue("inline"); 456var contentDisposition4 = new ContentDispositionHeaderValue("INLINE"); 457var contentDisposition5 = new ContentDispositionHeaderValue("INLINE"); 459var contentDisposition6 = new ContentDispositionHeaderValue("INLINE"); 462var contentDisposition7 = new ContentDispositionHeaderValue("attachment"); 478var expected = new ContentDispositionHeaderValue("inline"); 514var expected = new ContentDispositionHeaderValue("inline"); 540public static TheoryData<string, ContentDispositionHeaderValue> ValidContentDispositionTestCases = new TheoryData<string, ContentDispositionHeaderValue>() 594public void ContentDispositionHeaderValue_ParseValid_Success(string input, ContentDispositionHeaderValue expected) 597var result = ContentDispositionHeaderValue.Parse(input); 636Assert.Throws<FormatException>(() => ContentDispositionHeaderValue.Parse(input)); 646var result = ContentDispositionHeaderValue.Parse(contentDispositionLine); 655var contentDisposition = new ContentDispositionHeaderValue("attachment"); 679private void CheckValidParse(string? input, ContentDispositionHeaderValue expectedResult) 681var result = ContentDispositionHeaderValue.Parse(input); 687Assert.Throws<FormatException>(() => ContentDispositionHeaderValue.Parse(input)); 690private void CheckValidTryParse(string? input, ContentDispositionHeaderValue expectedResult) 692Assert.True(ContentDispositionHeaderValue.TryParse(input, out var result), input); 698Assert.False(ContentDispositionHeaderValue.TryParse(input, out var result), input);