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