From 9733704aea858f52b382812b96cf7ea64d99441a Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Tue, 11 Feb 2020 14:25:46 -0800 Subject: [PATCH] Update shared code for HTTP/2 and HTTP/3 (#18958) --- .../Core/src/Internal/Http2/Http2Connection.cs | 1 + src/Shared/Http2/IHttpHeadersHandler.cs | 1 + src/Shared/Http2/ReadMe.SharedCode.md | 2 +- src/Shared/Http3/QPack/QPackDecoder.cs | 13 ++++++++----- src/Shared/Http3/ReadMe.SharedCode.md | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs index eae49b48a1..848aca40c7 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs @@ -13,6 +13,7 @@ using System.Runtime.CompilerServices; using System.Security.Authentication; using System.Threading; using System.Threading.Tasks; +using System.Net.Http; using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Hosting.Server; diff --git a/src/Shared/Http2/IHttpHeadersHandler.cs b/src/Shared/Http2/IHttpHeadersHandler.cs index 311afa8c39..11a7e3473e 100644 --- a/src/Shared/Http2/IHttpHeadersHandler.cs +++ b/src/Shared/Http2/IHttpHeadersHandler.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +// Don't ever change this unless we are explicitly trying to remove IHttpHeadersHandler as public API. #if KESTREL using System; diff --git a/src/Shared/Http2/ReadMe.SharedCode.md b/src/Shared/Http2/ReadMe.SharedCode.md index 20e88283f4..eab9a4631e 100644 --- a/src/Shared/Http2/ReadMe.SharedCode.md +++ b/src/Shared/Http2/ReadMe.SharedCode.md @@ -14,7 +14,7 @@ aspnet/AspNetCore code paths: ## Building dotnet/runtime code: - https://github.com/dotnet/runtime/tree/master/docs/workflow -- Run libraries.cmd from the root once: `PS D:\github\runtime> .\libraries.cmd` +- Run *build.cmd* from the root once: `PS D:\github\runtime> .\build.cmd -subsetCategory libraries` - Build the individual projects: - `PS D:\github\dotnet\src\libraries\Common\tests> dotnet msbuild /t:rebuild` - `PS D:\github\dotnet\src\libraries\System.Net.Http\src> dotnet msbuild /t:rebuild` diff --git a/src/Shared/Http3/QPack/QPackDecoder.cs b/src/Shared/Http3/QPack/QPackDecoder.cs index 1893f9db5e..40bd7f0235 100644 --- a/src/Shared/Http3/QPack/QPackDecoder.cs +++ b/src/Shared/Http3/QPack/QPackDecoder.cs @@ -6,7 +6,10 @@ using System.Buffers; using System.Diagnostics; using System.Net.Http.HPack; using System.Numerics; + +#if KESTREL using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; +#endif namespace System.Net.Http.QPack { @@ -221,9 +224,9 @@ namespace System.Net.Http.QPack } break; case State.CompressedHeaders: - switch (BitOperations.LeadingZeroCount(b)) + switch (BitOperations.LeadingZeroCount(b) - 24) { - case 24: // Indexed Header Field + case 0: // Indexed Header Field prefixInt = IndexedHeaderFieldPrefixMask & b; bool useStaticTable = (b & IndexedHeaderStaticMask) == IndexedHeaderStaticRepresentation; @@ -242,7 +245,7 @@ namespace System.Net.Http.QPack _state = State.HeaderFieldIndex; } break; - case 25: // Literal Header Field With Name Reference + case 1: // Literal Header Field With Name Reference useStaticTable = (LiteralHeaderFieldStaticMask & b) == LiteralHeaderFieldStaticMask; if (!useStaticTable) @@ -260,7 +263,7 @@ namespace System.Net.Http.QPack _state = State.HeaderNameIndex; } break; - case 26: // Literal Header Field Without Name Reference + case 2: // Literal Header Field Without Name Reference _huffman = (b & LiteralHeaderFieldWithoutNameReferenceHuffmanMask) != 0; prefixInt = b & LiteralHeaderFieldWithoutNameReferencePrefixMask; @@ -273,7 +276,7 @@ namespace System.Net.Http.QPack _state = State.HeaderNameLength; } break; - case 27: // Indexed Header Field With Post-Base Index + case 3: // Indexed Header Field With Post-Base Index prefixInt = ~PostBaseIndexMask & b; if (_integerDecoder.BeginTryDecode((byte)prefixInt, PostBaseIndexPrefix, out intResult)) { diff --git a/src/Shared/Http3/ReadMe.SharedCode.md b/src/Shared/Http3/ReadMe.SharedCode.md index bbb04284ad..481789b602 100644 --- a/src/Shared/Http3/ReadMe.SharedCode.md +++ b/src/Shared/Http3/ReadMe.SharedCode.md @@ -14,7 +14,7 @@ To copy code from aspnet/AspNetCore to dotnet/runtime, set RUNTIME_REPO to the r ## Building dotnet/runtime code: - https://github.com/dotnet/runtime/blob/master/docs/libraries/building/windows-instructions.md - https://github.com/dotnet/runtime/blob/master/docs/libraries/project-docs/developer-guide.md -- Run libraries.cmd from the root once: `PS D:\github\runtime> .\libraries.cmd` +- Run *build.cmd* from the root once: `PS D:\github\runtime> .\build.cmd -subsetCategory libraries` - Build the individual projects: - `PS D:\github\dotnet\src\libraries\Common\tests> dotnet msbuild /t:rebuild` - `PS D:\github\dotnet\src\libraries\System.Net.Http\src> dotnet msbuild /t:rebuild`