@@ -16,7 +16,7 @@ public class HttpRequestHeadersTests
16
16
[ Fact ]
17
17
public void InitialDictionaryIsEmpty ( )
18
18
{
19
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
19
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
20
20
21
21
Assert . Equal ( 0 , headers . Count ) ;
22
22
Assert . False ( headers . IsReadOnly ) ;
@@ -25,7 +25,7 @@ public void InitialDictionaryIsEmpty()
25
25
[ Fact ]
26
26
public void SettingUnknownHeadersWorks ( )
27
27
{
28
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
28
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
29
29
30
30
headers [ "custom" ] = new [ ] { "value" } ;
31
31
@@ -36,7 +36,7 @@ public void SettingUnknownHeadersWorks()
36
36
[ Fact ]
37
37
public void SettingKnownHeadersWorks ( )
38
38
{
39
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
39
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
40
40
41
41
headers [ "host" ] = new [ ] { "value" } ;
42
42
headers [ "content-length" ] = new [ ] { "0" } ;
@@ -50,7 +50,7 @@ public void SettingKnownHeadersWorks()
50
50
[ Fact ]
51
51
public void KnownAndCustomHeaderCountAddedTogether ( )
52
52
{
53
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
53
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
54
54
55
55
headers [ "host" ] = new [ ] { "value" } ;
56
56
headers [ "custom" ] = new [ ] { "value" } ;
@@ -62,7 +62,7 @@ public void KnownAndCustomHeaderCountAddedTogether()
62
62
[ Fact ]
63
63
public void TryGetValueWorksForKnownAndUnknownHeaders ( )
64
64
{
65
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
65
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
66
66
67
67
StringValues value ;
68
68
Assert . False ( headers . TryGetValue ( "host" , out value ) ) ;
@@ -88,7 +88,7 @@ public void TryGetValueWorksForKnownAndUnknownHeaders()
88
88
[ Fact ]
89
89
public void SameExceptionThrownForMissingKey ( )
90
90
{
91
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
91
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
92
92
93
93
Assert . Throws < KeyNotFoundException > ( ( ) => headers [ "custom" ] ) ;
94
94
Assert . Throws < KeyNotFoundException > ( ( ) => headers [ "host" ] ) ;
@@ -98,7 +98,7 @@ public void SameExceptionThrownForMissingKey()
98
98
[ Fact ]
99
99
public void EntriesCanBeEnumerated ( )
100
100
{
101
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
101
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
102
102
var v1 = new [ ] { "localhost" } ;
103
103
var v2 = new [ ] { "0" } ;
104
104
var v3 = new [ ] { "value" } ;
@@ -118,7 +118,7 @@ public void EntriesCanBeEnumerated()
118
118
[ Fact ]
119
119
public void KeysAndValuesCanBeEnumerated ( )
120
120
{
121
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
121
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
122
122
StringValues v1 = new [ ] { "localhost" } ;
123
123
StringValues v2 = new [ ] { "0" } ;
124
124
StringValues v3 = new [ ] { "value" } ;
@@ -138,7 +138,7 @@ public void KeysAndValuesCanBeEnumerated()
138
138
[ Fact ]
139
139
public void ContainsAndContainsKeyWork ( )
140
140
{
141
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
141
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
142
142
var kv1 = new KeyValuePair < string , StringValues > ( "host" , new [ ] { "localhost" } ) ;
143
143
var kv2 = new KeyValuePair < string , StringValues > ( "custom" , new [ ] { "value" } ) ;
144
144
var kv3 = new KeyValuePair < string , StringValues > ( "Content-Length" , new [ ] { "0" } ) ;
@@ -190,7 +190,7 @@ public void ContainsAndContainsKeyWork()
190
190
[ Fact ]
191
191
public void AddWorksLikeSetAndThrowsIfKeyExists ( )
192
192
{
193
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
193
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
194
194
195
195
StringValues value ;
196
196
Assert . False ( headers . TryGetValue ( "host" , out value ) ) ;
@@ -215,7 +215,7 @@ public void AddWorksLikeSetAndThrowsIfKeyExists()
215
215
[ Fact ]
216
216
public void ClearRemovesAllHeaders ( )
217
217
{
218
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
218
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
219
219
headers . Add ( "host" , new [ ] { "localhost" } ) ;
220
220
headers . Add ( "custom" , new [ ] { "value" } ) ;
221
221
headers . Add ( "Content-Length" , new [ ] { "0" } ) ;
@@ -237,7 +237,7 @@ public void ClearRemovesAllHeaders()
237
237
[ Fact ]
238
238
public void RemoveTakesHeadersOutOfDictionary ( )
239
239
{
240
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
240
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
241
241
headers . Add ( "host" , new [ ] { "localhost" } ) ;
242
242
headers . Add ( "custom" , new [ ] { "value" } ) ;
243
243
headers . Add ( "Content-Length" , new [ ] { "0" } ) ;
@@ -275,7 +275,7 @@ public void RemoveTakesHeadersOutOfDictionary()
275
275
[ Fact ]
276
276
public void CopyToMovesDataIntoArray ( )
277
277
{
278
- IDictionary < string , StringValues > headers = new HttpRequestHeaders ( ) ;
278
+ IDictionary < string , StringValues > headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
279
279
headers . Add ( "host" , new [ ] { "localhost" } ) ;
280
280
headers . Add ( "Content-Length" , new [ ] { "0" } ) ;
281
281
headers . Add ( "custom" , new [ ] { "value" } ) ;
@@ -302,12 +302,12 @@ public void CopyToMovesDataIntoArray()
302
302
[ Fact ]
303
303
public void AppendThrowsWhenHeaderNameContainsNonASCIICharacters ( )
304
304
{
305
- var headers = new HttpRequestHeaders ( ) ;
305
+ var headers = new HttpRequestHeaders ( new KestrelServerOptions ( ) ) ;
306
306
const string key = "\u0014 1\u00F3 d\0 17c" ;
307
307
308
308
var encoding = Encoding . GetEncoding ( "iso-8859-1" ) ;
309
309
var exception = Assert . Throws < BadHttpRequestException > (
310
- ( ) => headers . Append ( encoding . GetBytes ( key ) , "value" ) ) ;
310
+ ( ) => headers . Append ( encoding . GetBytes ( key ) , Encoding . ASCII . GetBytes ( "value" ) ) ) ;
311
311
Assert . Equal ( StatusCodes . Status400BadRequest , exception . StatusCode ) ;
312
312
}
313
313
}
0 commit comments