16 writes to Parameters
Microsoft.Net.Http.Headers.Tests (16)
ContentDispositionHeaderValueTest.cs (16)
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. 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. 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 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). 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) 570{ @"attachment; xfilename=foo.html", new ContentDispositionHeaderValue("attachment" ) { Parameters = { new NameValueHeaderValue("xfilename", "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""") } } }, 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. 586{ @"attachment; foobar=x; filename=""foo.html""", new ContentDispositionHeaderValue("attachment") { FileName = @"""foo.html""", Parameters = { new NameValueHeaderValue("foobar", "x") } } },
96 references to Parameters
Microsoft.Net.Http.Headers (4)
ContentDispositionHeaderValue.cs (4)
191Parameters.Add(new NameValueHeaderValue(SizeString, sizeString)); 303contentDispositionHeader.Parameters); 394Parameters.Add(new NameValueHeaderValue(parameter, dateString)); 459Parameters.Add(new NameValueHeaderValue(parameter, processedValue));
Microsoft.Net.Http.Headers.Tests (92)
ContentDispositionHeaderValueTest.cs (92)
46Assert.Empty(contentDisposition.Parameters); 59Assert.Throws<ArgumentNullException>(() => contentDisposition.Parameters.Add(null!)); 78Assert.Single(contentDisposition.Parameters); 79Assert.Equal("name", contentDisposition.Parameters.First().Name.AsSpan()); 83Assert.Empty(contentDisposition.Parameters); 94contentDisposition.Parameters.Add(name); 95Assert.Single(contentDisposition.Parameters); 96Assert.Equal("NAME", contentDisposition.Parameters.First().Name.AsSpan()); 100Assert.Single(contentDisposition.Parameters); 101Assert.Equal("NAME", contentDisposition.Parameters.First().Name.AsSpan()); 103contentDisposition.Parameters.Remove(name); 114contentDisposition.Parameters.Add(fileName); 115Assert.Single(contentDisposition.Parameters); 116Assert.Equal("FILENAME", contentDisposition.Parameters.First().Name.AsSpan()); 120Assert.Single(contentDisposition.Parameters); 121Assert.Equal("FILENAME", contentDisposition.Parameters.First().Name.AsSpan()); 123contentDisposition.Parameters.Remove(fileName); 134Assert.Single(contentDisposition.Parameters); 135Assert.Equal("filename", contentDisposition.Parameters.First().Name.AsSpan()); 136Assert.Equal("\"=?utf-8?B?RmlsZcODTmFtZS5iYXQ=?=\"", contentDisposition.Parameters.First().Value.AsSpan()); 138contentDisposition.Parameters.Remove(contentDisposition.Parameters.First()); 149Assert.Single(contentDisposition.Parameters); 150Assert.Equal("filename", contentDisposition.Parameters.First().Name.AsSpan()); 151Assert.Equal("\"=?utf-8?B?RmlsZQpOYW1lLmJhdA==?=\"", contentDisposition.Parameters.First().Value.AsSpan()); 153contentDisposition.Parameters.Remove(contentDisposition.Parameters.First()); 164contentDisposition.Parameters.Add(fileName); 165Assert.Single(contentDisposition.Parameters); 166Assert.Equal("FILENAME", contentDisposition.Parameters.First().Name.AsSpan()); 167Assert.Equal("\"=?utf-99?Q?R=mlsZcODTmFtZS5iYXQ=?=\"", contentDisposition.Parameters.First().Value.AsSpan()); 172Assert.Single(contentDisposition.Parameters); 173Assert.Equal("FILENAME", contentDisposition.Parameters.First().Name.AsSpan()); 175contentDisposition.Parameters.Remove(fileName); 186contentDisposition.Parameters.Add(fileNameStar); 187Assert.Single(contentDisposition.Parameters); 188Assert.Equal("FILENAME*", contentDisposition.Parameters.First().Name.AsSpan()); 193Assert.Single(contentDisposition.Parameters); 194Assert.Equal("FILENAME*", contentDisposition.Parameters.First().Name.AsSpan()); 195Assert.Equal("UTF-8\'\'new_name", contentDisposition.Parameters.First().Value.AsSpan()); 197contentDisposition.Parameters.Remove(fileNameStar); 208Assert.Single(contentDisposition.Parameters); 209Assert.Equal("filename*", contentDisposition.Parameters.First().Name.AsSpan()); 210Assert.Equal("UTF-8\'\'File%C3%83Name.bat", contentDisposition.Parameters.First().Value.AsSpan()); 212contentDisposition.Parameters.Remove(contentDisposition.Parameters.First()); 221Assert.Equal($"UTF-8\'\'a%C2%80b", contentDisposition.Parameters.First().Value.AsSpan()); //%C2 added because the value in UTF-8 is encoded on 2 bytes. 229Assert.Equal($"UTF-8\'\'{new string('a', 400)}", contentDisposition.Parameters.First().Value.AsSpan()); 253Assert.Equal($"UTF-8\'\'a%{hexC}b", contentDisposition.Parameters.First().Value.AsSpan()); 257Assert.Equal($"UTF-8\'\'a{(char)b}b", contentDisposition.Parameters.First().Value.AsSpan()); 259contentDisposition.Parameters.Remove(contentDisposition.Parameters.First()); 270contentDisposition.Parameters.Add(fileNameStar); 271Assert.Single(contentDisposition.Parameters); 272Assert.Equal("FILENAME*", contentDisposition.Parameters.First().Name.AsSpan()); 273Assert.Equal("utf-99'lang'File%CZName.bat", contentDisposition.Parameters.First().Value.AsSpan()); 278Assert.Single(contentDisposition.Parameters); 279Assert.Equal("FILENAME*", contentDisposition.Parameters.First().Name.AsSpan()); 281contentDisposition.Parameters.Remove(fileNameStar); 311contentDisposition.Parameters.Add(dateParameter); 312Assert.Single(contentDisposition.Parameters); 313Assert.Equal("Creation-DATE", contentDisposition.Parameters.First().Name.AsSpan()); 320Assert.Single(contentDisposition.Parameters); 321Assert.Equal("Creation-DATE", contentDisposition.Parameters.First().Name.AsSpan()); 322Assert.Equal("\"Tue, 15 Nov 1994 08:12:32 GMT\"", contentDisposition.Parameters.First().Value.AsSpan()); 324contentDisposition.Parameters.Remove(dateParameter); 337contentDisposition.Parameters.Add(dateParameter); 338Assert.Single(contentDisposition.Parameters); 339Assert.Equal("read-DATE", contentDisposition.Parameters.First().Name.AsSpan()); 345Assert.Empty(contentDisposition.Parameters); 355contentDisposition.Parameters.Add(sizeParameter); 356Assert.Single(contentDisposition.Parameters); 357Assert.Equal("SIZE", contentDisposition.Parameters.First().Name.AsSpan()); 362Assert.Single(contentDisposition.Parameters); 363Assert.Equal("SIZE", contentDisposition.Parameters.First().Name.AsSpan()); 365contentDisposition.Parameters.Remove(sizeParameter); 376contentDisposition.Parameters.Add(sizeParameter); 377Assert.Single(contentDisposition.Parameters); 378Assert.Equal("SIZE", contentDisposition.Parameters.First().Name.AsSpan()); 384Assert.Single(contentDisposition.Parameters); 385Assert.Equal("SIZE", contentDisposition.Parameters.First().Name.AsSpan()); 387contentDisposition.Parameters.Remove(sizeParameter); 407contentDisposition.Parameters.Add(new NameValueHeaderValue("custom", "\"custom value\"")); 436contentDisposition3.Parameters.Add(new NameValueHeaderValue("name", "value")); 439contentDisposition5.Parameters.Add(new NameValueHeaderValue("NAME", "MYNAME")); 455contentDisposition3.Parameters.Add(new NameValueHeaderValue("name", "value")); 458contentDisposition5.Parameters.Add(new NameValueHeaderValue("NAME", "MYNAME")); 460contentDisposition6.Parameters.Add(new NameValueHeaderValue("NAME", "MYNAME")); 461contentDisposition6.Parameters.Add(new NameValueHeaderValue("custom", "value")); 492expected.Parameters.Add(new NameValueHeaderValue("filename*", "UTF-8''foo-%c3%a4.html")); 659Assert.Equal(2, contentDisposition.Parameters.Count); 660Assert.Equal("UTF-8\'\'File%20%F0%9F%A4%A9%20name.txt", contentDisposition.Parameters[1].Value.AsSpan());