diff --git a/src/Kestrel.Core/Internal/Http2/HPack/StaticTable.cs b/src/Kestrel.Core/Internal/Http2/HPack/StaticTable.cs index c28a78ff8d..0b8b533bb4 100644 --- a/src/Kestrel.Core/Internal/Http2/HPack/StaticTable.cs +++ b/src/Kestrel.Core/Internal/Http2/HPack/StaticTable.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack { @@ -35,20 +36,20 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack private readonly HeaderField[] _staticTable = new HeaderField[] { - CreateHeaderField(":authority", ""), - CreateHeaderField(":method", "GET"), - CreateHeaderField(":method", "POST"), - CreateHeaderField(":path", "/"), - CreateHeaderField(":path", "/index.html"), - CreateHeaderField(":scheme", "http"), - CreateHeaderField(":scheme", "https"), - CreateHeaderField(":status", "200"), - CreateHeaderField(":status", "204"), - CreateHeaderField(":status", "206"), - CreateHeaderField(":status", "304"), - CreateHeaderField(":status", "400"), - CreateHeaderField(":status", "404"), - CreateHeaderField(":status", "500"), + CreateHeaderField(HeaderNames.Authority, ""), + CreateHeaderField(HeaderNames.Method, "GET"), + CreateHeaderField(HeaderNames.Method, "POST"), + CreateHeaderField(HeaderNames.Path, "/"), + CreateHeaderField(HeaderNames.Path, "/index.html"), + CreateHeaderField(HeaderNames.Scheme, "http"), + CreateHeaderField(HeaderNames.Scheme, "https"), + CreateHeaderField(HeaderNames.Status, "200"), + CreateHeaderField(HeaderNames.Status, "204"), + CreateHeaderField(HeaderNames.Status, "206"), + CreateHeaderField(HeaderNames.Status, "304"), + CreateHeaderField(HeaderNames.Status, "400"), + CreateHeaderField(HeaderNames.Status, "404"), + CreateHeaderField(HeaderNames.Status, "500"), CreateHeaderField("accept-charset", ""), CreateHeaderField("accept-encoding", "gzip, deflate"), CreateHeaderField("accept-language", ""), diff --git a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs index f458436662..58646cca12 100644 --- a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs +++ b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.Extensions.Logging; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 { @@ -45,11 +46,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 private static readonly PseudoHeaderFields _mandatoryRequestPseudoHeaderFields = PseudoHeaderFields.Method | PseudoHeaderFields.Path | PseudoHeaderFields.Scheme; - private static readonly byte[] _authorityBytes = Encoding.ASCII.GetBytes("authority"); - private static readonly byte[] _methodBytes = Encoding.ASCII.GetBytes("method"); - private static readonly byte[] _pathBytes = Encoding.ASCII.GetBytes("path"); - private static readonly byte[] _schemeBytes = Encoding.ASCII.GetBytes("scheme"); - private static readonly byte[] _statusBytes = Encoding.ASCII.GetBytes("status"); + private static readonly byte[] _authorityBytes = Encoding.ASCII.GetBytes(HeaderNames.Authority); + private static readonly byte[] _methodBytes = Encoding.ASCII.GetBytes(HeaderNames.Method); + private static readonly byte[] _pathBytes = Encoding.ASCII.GetBytes(HeaderNames.Path); + private static readonly byte[] _schemeBytes = Encoding.ASCII.GetBytes(HeaderNames.Scheme); + private static readonly byte[] _statusBytes = Encoding.ASCII.GetBytes(HeaderNames.Status); private static readonly byte[] _connectionBytes = Encoding.ASCII.GetBytes("connection"); private static readonly byte[] _teBytes = Encoding.ASCII.GetBytes("te"); private static readonly byte[] _trailersBytes = Encoding.ASCII.GetBytes("trailers"); @@ -803,9 +804,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 return false; } - // Skip ':' - name = name.Slice(1); - if (name.SequenceEqual(_pathBytes)) { headerField = PseudoHeaderFields.Path; diff --git a/src/Kestrel.Core/Internal/Http2/Http2Stream.cs b/src/Kestrel.Core/Internal/Http2/Http2Stream.cs index 0234879a37..702cd636d5 100644 --- a/src/Kestrel.Core/Internal/Http2/Http2Stream.cs +++ b/src/Kestrel.Core/Internal/Http2/Http2Stream.cs @@ -57,15 +57,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 // do the reading from a pipeline, nor do we use endConnection to report connection-level errors. _httpVersion = Http.HttpVersion.Http2; - var methodText = RequestHeaders[":method"]; + var methodText = RequestHeaders[HeaderNames.Method]; Method = HttpUtilities.GetKnownMethod(methodText); _methodText = methodText; - if (!string.Equals(RequestHeaders[":scheme"], Scheme, StringComparison.OrdinalIgnoreCase)) + if (!string.Equals(RequestHeaders[HeaderNames.Scheme], Scheme, StringComparison.OrdinalIgnoreCase)) { BadHttpRequestException.Throw(RequestRejectionReason.InvalidRequestLine); } - var path = RequestHeaders[":path"].ToString(); + var path = RequestHeaders[HeaderNames.Path].ToString(); var queryIndex = path.IndexOf('?'); Path = queryIndex == -1 ? path : path.Substring(0, queryIndex); @@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 // request message that contains more than one Host header field or a // Host header field with an invalid field-value. - var authority = RequestHeaders[":authority"]; + var authority = RequestHeaders[HeaderNames.Authority]; var host = HttpRequestHeaders.HeaderHost; if (authority.Count > 0) { diff --git a/test/Kestrel.Core.Tests/HPackDecoderTests.cs b/test/Kestrel.Core.Tests/HPackDecoderTests.cs index a20c0be120..28878c6864 100644 --- a/test/Kestrel.Core.Tests/HPackDecoderTests.cs +++ b/test/Kestrel.Core.Tests/HPackDecoderTests.cs @@ -8,6 +8,7 @@ using System.Text; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests @@ -104,7 +105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests public void DecodesIndexedHeaderField_StaticTable() { _decoder.Decode(_indexedHeaderStatic, endHeaders: true, handler: this); - Assert.Equal("GET", _decodedHeaders[":method"]); + Assert.Equal("GET", _decodedHeaders[HeaderNames.Method]); } [Fact] diff --git a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs index 7afba1e572..549ec6a007 100644 --- a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs +++ b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs @@ -31,27 +31,27 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests private static readonly IEnumerable> _postRequestHeaders = new[] { - new KeyValuePair(":method", "POST"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "localhost:80"), + new KeyValuePair(HeaderNames.Method, "POST"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "localhost:80"), }; private static readonly IEnumerable> _expectContinueRequestHeaders = new[] { - new KeyValuePair(":method", "POST"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":authority", "127.0.0.1"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "POST"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Authority, "127.0.0.1"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair("expect", "100-continue"), }; private static readonly IEnumerable> _browserRequestHeaders = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "localhost:80"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "localhost:80"), new KeyValuePair("user-agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"), new KeyValuePair("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), new KeyValuePair("accept-language", "en-US,en;q=0.5"), @@ -67,10 +67,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests private static readonly IEnumerable> _oneContinuationRequestHeaders = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "localhost:80"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "localhost:80"), new KeyValuePair("a", _largeHeaderValue), new KeyValuePair("b", _largeHeaderValue), new KeyValuePair("c", _largeHeaderValue), @@ -79,10 +79,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests private static readonly IEnumerable> _twoContinuationsRequestHeaders = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "localhost:80"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "localhost:80"), new KeyValuePair("a", _largeHeaderValue), new KeyValuePair("b", _largeHeaderValue), new KeyValuePair("c", _largeHeaderValue), @@ -1078,9 +1078,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair(":unknown", "0"), }; @@ -1092,10 +1092,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":status", "200"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Status, "200"), }; return HEADERS_Received_InvalidHeaderFields_StreamError(headers, expectedErrorMessage: CoreStrings.Http2ErrorResponsePseudoHeaderField); @@ -1167,9 +1167,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair("connection", "keep-alive") }; @@ -1181,9 +1181,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair("te", "trailers, deflate") }; @@ -1195,9 +1195,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair("te", "trailers") }; @@ -1222,10 +1222,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "local=host:80"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "local=host:80"), }; await InitializeConnectionAsync(_noopApplication); @@ -1246,7 +1246,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(3, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("400", _decodedHeaders[":status"]); + Assert.Equal("400", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders["content-length"]); } @@ -1255,9 +1255,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), }; await InitializeConnectionAsync(_noopApplication); @@ -1278,7 +1278,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(3, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("400", _decodedHeaders[":status"]); + Assert.Equal("400", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders["content-length"]); } @@ -1287,9 +1287,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair("Host", "host1"), new KeyValuePair("Host", "host2"), }; @@ -1312,7 +1312,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(3, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("400", _decodedHeaders[":status"]); + Assert.Equal("400", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders["content-length"]); } @@ -1321,10 +1321,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", ""), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, ""), }; await InitializeConnectionAsync(_noopApplication); @@ -1345,7 +1345,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(3, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("200", _decodedHeaders[":status"]); + Assert.Equal("200", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders["content-length"]); } @@ -1354,10 +1354,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", ""), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, ""), new KeyValuePair("Host", "abc"), }; await InitializeConnectionAsync(_echoHost); @@ -1379,7 +1379,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(4, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("200", _decodedHeaders[":status"]); + Assert.Equal("200", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders[HeaderNames.ContentLength]); Assert.Equal("", _decodedHeaders[HeaderNames.Host]); } @@ -1389,10 +1389,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "def"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "def"), new KeyValuePair("Host", "abc"), }; await InitializeConnectionAsync(_echoHost); @@ -1414,7 +1414,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(4, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("200", _decodedHeaders[":status"]); + Assert.Equal("200", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders[HeaderNames.ContentLength]); Assert.Equal("def", _decodedHeaders[HeaderNames.Host]); } @@ -1424,9 +1424,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair("Host", "abc"), }; await InitializeConnectionAsync(_echoHost); @@ -1448,7 +1448,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(4, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("200", _decodedHeaders[":status"]); + Assert.Equal("200", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders[HeaderNames.ContentLength]); Assert.Equal("abc", _decodedHeaders[HeaderNames.Host]); } @@ -1458,10 +1458,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "def"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "def"), new KeyValuePair("Host", "a=bc"), }; await InitializeConnectionAsync(_echoHost); @@ -1483,7 +1483,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(4, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("200", _decodedHeaders[":status"]); + Assert.Equal("200", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders[HeaderNames.ContentLength]); Assert.Equal("def", _decodedHeaders[HeaderNames.Host]); } @@ -1493,10 +1493,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var headers = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "d=ef"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "d=ef"), new KeyValuePair("Host", "abc"), }; await InitializeConnectionAsync(_echoHost); @@ -1518,7 +1518,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(3, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("400", _decodedHeaders[":status"]); + Assert.Equal("400", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders[HeaderNames.ContentLength]); } @@ -2242,7 +2242,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(11, _decodedHeaders.Count); Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase); - Assert.Equal("200", _decodedHeaders[":status"]); + Assert.Equal("200", _decodedHeaders[HeaderNames.Status]); Assert.Equal("0", _decodedHeaders["content-length"]); Assert.Equal(_largeHeaderValue, _decodedHeaders["a"]); Assert.Equal(_largeHeaderValue, _decodedHeaders["b"]); @@ -2968,10 +2968,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests var data = new TheoryData>>(); var requestHeaders = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":authority", "127.0.0.1"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Authority, "127.0.0.1"), + new KeyValuePair(HeaderNames.Scheme, "http"), }; foreach (var headerField in requestHeaders) @@ -2991,9 +2991,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests var data = new TheoryData>>(); var requestHeaders = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), }; foreach (var headerField in requestHeaders) @@ -3011,12 +3011,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests get { var data = new TheoryData>>(); - var methodHeader = new[] { new KeyValuePair(":method", "CONNECT") }; + var methodHeader = new[] { new KeyValuePair(HeaderNames.Method, "CONNECT") }; var requestHeaders = new[] { - new KeyValuePair(":path", "/"), - new KeyValuePair(":scheme", "http"), - new KeyValuePair(":authority", "127.0.0.1"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Scheme, "http"), + new KeyValuePair(HeaderNames.Authority, "127.0.0.1"), }; foreach (var headerField in requestHeaders) @@ -3036,10 +3036,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests var data = new TheoryData>>(); var requestHeaders = new[] { - new KeyValuePair(":method", "GET"), - new KeyValuePair(":path", "/"), - new KeyValuePair(":authority", "127.0.0.1"), - new KeyValuePair(":scheme", "http"), + new KeyValuePair(HeaderNames.Method, "GET"), + new KeyValuePair(HeaderNames.Path, "/"), + new KeyValuePair(HeaderNames.Authority, "127.0.0.1"), + new KeyValuePair(HeaderNames.Scheme, "http"), new KeyValuePair("content-length", "0") };