Skip to content

Commit fcc097a

Browse files
committed
Tests react to change
1 parent 8460ce5 commit fcc097a

File tree

11 files changed

+88
-71
lines changed

11 files changed

+88
-71
lines changed

src/Servers/Kestrel/Core/test/HPackDecoderTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ void IHttpHeadersHandler.OnHeader(Span<byte> name, Span<byte> value)
103103
_decodedHeaders[name.GetAsciiStringNonNullCharacters()] = value.GetAsciiStringNonNullCharacters();
104104
}
105105

106+
void IHttpHeadersHandler.OnHeadersComplete() { }
107+
106108
[Fact]
107109
public void DecodesIndexedHeaderField_StaticTable()
108110
{

src/Servers/Kestrel/Core/test/Http1ConnectionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public void ResetResetsRequestHeaders()
325325
{
326326
// Arrange
327327
var originalRequestHeaders = _http1Connection.RequestHeaders;
328-
_http1Connection.RequestHeaders = new HttpRequestHeaders();
328+
_http1Connection.RequestHeaders = new HttpRequestHeaders(new KestrelServerOptions());
329329

330330
// Act
331331
_http1Connection.Reset();

src/Servers/Kestrel/Core/test/HttpHeadersTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void TestParseTransferEncodingMultipleValues(string value1, string value2
217217
[Fact]
218218
public void ValidContentLengthsAccepted()
219219
{
220-
ValidContentLengthsAcceptedImpl(new HttpRequestHeaders());
220+
ValidContentLengthsAcceptedImpl(new HttpRequestHeaders(new KestrelServerOptions()));
221221
ValidContentLengthsAcceptedImpl(new HttpResponseHeaders());
222222
}
223223

@@ -250,7 +250,7 @@ private static void ValidContentLengthsAcceptedImpl(HttpHeaders httpHeaders)
250250
[Fact]
251251
public void InvalidContentLengthsRejected()
252252
{
253-
InvalidContentLengthsRejectedImpl(new HttpRequestHeaders());
253+
InvalidContentLengthsRejectedImpl(new HttpRequestHeaders(new KestrelServerOptions()));
254254
InvalidContentLengthsRejectedImpl(new HttpResponseHeaders());
255255
}
256256

src/Servers/Kestrel/Core/test/HttpParserTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ public void OnHeader(Span<byte> name, Span<byte> value)
483483
Headers[name.GetAsciiStringNonNullCharacters()] = value.GetAsciiStringNonNullCharacters();
484484
}
485485

486+
void IHttpHeadersHandler.OnHeadersComplete() { }
487+
486488
public void OnStartLine(HttpMethod method, HttpVersion version, Span<byte> target, Span<byte> path, Span<byte> query, Span<byte> customMethod, bool pathEncoded)
487489
{
488490
Method = method != HttpMethod.Custom ? HttpUtilities.MethodToString(method) : customMethod.GetAsciiStringNonNullCharacters();

src/Servers/Kestrel/Core/test/HttpRequestHeadersTests.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class HttpRequestHeadersTests
1616
[Fact]
1717
public void InitialDictionaryIsEmpty()
1818
{
19-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
19+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
2020

2121
Assert.Equal(0, headers.Count);
2222
Assert.False(headers.IsReadOnly);
@@ -25,7 +25,7 @@ public void InitialDictionaryIsEmpty()
2525
[Fact]
2626
public void SettingUnknownHeadersWorks()
2727
{
28-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
28+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
2929

3030
headers["custom"] = new[] { "value" };
3131

@@ -36,7 +36,7 @@ public void SettingUnknownHeadersWorks()
3636
[Fact]
3737
public void SettingKnownHeadersWorks()
3838
{
39-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
39+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
4040

4141
headers["host"] = new[] { "value" };
4242
headers["content-length"] = new[] { "0" };
@@ -50,7 +50,7 @@ public void SettingKnownHeadersWorks()
5050
[Fact]
5151
public void KnownAndCustomHeaderCountAddedTogether()
5252
{
53-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
53+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
5454

5555
headers["host"] = new[] { "value" };
5656
headers["custom"] = new[] { "value" };
@@ -62,7 +62,7 @@ public void KnownAndCustomHeaderCountAddedTogether()
6262
[Fact]
6363
public void TryGetValueWorksForKnownAndUnknownHeaders()
6464
{
65-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
65+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
6666

6767
StringValues value;
6868
Assert.False(headers.TryGetValue("host", out value));
@@ -88,7 +88,7 @@ public void TryGetValueWorksForKnownAndUnknownHeaders()
8888
[Fact]
8989
public void SameExceptionThrownForMissingKey()
9090
{
91-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
91+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
9292

9393
Assert.Throws<KeyNotFoundException>(() => headers["custom"]);
9494
Assert.Throws<KeyNotFoundException>(() => headers["host"]);
@@ -98,7 +98,7 @@ public void SameExceptionThrownForMissingKey()
9898
[Fact]
9999
public void EntriesCanBeEnumerated()
100100
{
101-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
101+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
102102
var v1 = new[] { "localhost" };
103103
var v2 = new[] { "0" };
104104
var v3 = new[] { "value" };
@@ -118,7 +118,7 @@ public void EntriesCanBeEnumerated()
118118
[Fact]
119119
public void KeysAndValuesCanBeEnumerated()
120120
{
121-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
121+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
122122
StringValues v1 = new[] { "localhost" };
123123
StringValues v2 = new[] { "0" };
124124
StringValues v3 = new[] { "value" };
@@ -138,7 +138,7 @@ public void KeysAndValuesCanBeEnumerated()
138138
[Fact]
139139
public void ContainsAndContainsKeyWork()
140140
{
141-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
141+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
142142
var kv1 = new KeyValuePair<string, StringValues>("host", new[] { "localhost" });
143143
var kv2 = new KeyValuePair<string, StringValues>("custom", new[] { "value" });
144144
var kv3 = new KeyValuePair<string, StringValues>("Content-Length", new[] { "0" });
@@ -190,7 +190,7 @@ public void ContainsAndContainsKeyWork()
190190
[Fact]
191191
public void AddWorksLikeSetAndThrowsIfKeyExists()
192192
{
193-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
193+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
194194

195195
StringValues value;
196196
Assert.False(headers.TryGetValue("host", out value));
@@ -215,7 +215,7 @@ public void AddWorksLikeSetAndThrowsIfKeyExists()
215215
[Fact]
216216
public void ClearRemovesAllHeaders()
217217
{
218-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
218+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
219219
headers.Add("host", new[] { "localhost" });
220220
headers.Add("custom", new[] { "value" });
221221
headers.Add("Content-Length", new[] { "0" });
@@ -237,7 +237,7 @@ public void ClearRemovesAllHeaders()
237237
[Fact]
238238
public void RemoveTakesHeadersOutOfDictionary()
239239
{
240-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
240+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
241241
headers.Add("host", new[] { "localhost" });
242242
headers.Add("custom", new[] { "value" });
243243
headers.Add("Content-Length", new[] { "0" });
@@ -275,7 +275,7 @@ public void RemoveTakesHeadersOutOfDictionary()
275275
[Fact]
276276
public void CopyToMovesDataIntoArray()
277277
{
278-
IDictionary<string, StringValues> headers = new HttpRequestHeaders();
278+
IDictionary<string, StringValues> headers = new HttpRequestHeaders(new KestrelServerOptions());
279279
headers.Add("host", new[] { "localhost" });
280280
headers.Add("Content-Length", new[] { "0" });
281281
headers.Add("custom", new[] { "value" });
@@ -302,12 +302,12 @@ public void CopyToMovesDataIntoArray()
302302
[Fact]
303303
public void AppendThrowsWhenHeaderNameContainsNonASCIICharacters()
304304
{
305-
var headers = new HttpRequestHeaders();
305+
var headers = new HttpRequestHeaders(new KestrelServerOptions());
306306
const string key = "\u00141\u00F3d\017c";
307307

308308
var encoding = Encoding.GetEncoding("iso-8859-1");
309309
var exception = Assert.Throws<BadHttpRequestException>(
310-
() => headers.Append(encoding.GetBytes(key), "value"));
310+
() => headers.Append(encoding.GetBytes(key), Encoding.ASCII.GetBytes("value")));
311311
Assert.Equal(StatusCodes.Status400BadRequest, exception.StatusCode);
312312
}
313313
}

0 commit comments

Comments
 (0)