From bd7c89aa201c4bf80da2f02f920f1bbbd7109e06 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 4 Dec 2019 09:40:17 -0800 Subject: [PATCH] Pubternal IHttpHeadersHandler (#17573) --- ...t.AspNetCore.Server.Kestrel.Core.netcoreapp.cs | 12 ++++++++++++ .../Kestrel/Core/src/Internal/Http/HttpParser.cs | 2 +- .../Core/src/Internal/Http3/QPack/QPackDecoder.cs | 2 +- ...icrosoft.AspNetCore.Server.Kestrel.Core.csproj | 1 + ...ft.AspNetCore.Server.Kestrel.Core.Tests.csproj | 1 + src/Shared/Http2/Hpack/HPackDecoder.cs | 3 +++ src/Shared/Http2/IHttpHeadersHandler.cs | 15 +++++++++++++-- .../test/Shared.Tests/Http2/HPackDecoderTest.cs | 3 +++ 8 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Servers/Kestrel/Core/ref/Microsoft.AspNetCore.Server.Kestrel.Core.netcoreapp.cs b/src/Servers/Kestrel/Core/ref/Microsoft.AspNetCore.Server.Kestrel.Core.netcoreapp.cs index 6600b52b48..5bd3bcd410 100644 --- a/src/Servers/Kestrel/Core/ref/Microsoft.AspNetCore.Server.Kestrel.Core.netcoreapp.cs +++ b/src/Servers/Kestrel/Core/ref/Microsoft.AspNetCore.Server.Kestrel.Core.netcoreapp.cs @@ -214,6 +214,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http Custom = (byte)9, None = (byte)255, } + public partial class HttpParser where TRequestHandler : Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.IHttpHeadersHandler, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.IHttpRequestLineHandler + { + public HttpParser() { } + public HttpParser(bool showErrorDetails) { } + public bool ParseHeaders(TRequestHandler handler, ref System.Buffers.SequenceReader reader) { throw null; } + public bool ParseRequestLine(TRequestHandler handler, in System.Buffers.ReadOnlySequence buffer, out System.SequencePosition consumed, out System.SequencePosition examined) { throw null; } + } public enum HttpScheme { Unknown = -1, @@ -228,6 +235,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http Http2 = 2, Http3 = 3, } + public partial interface IHttpHeadersHandler + { + void OnHeader(System.ReadOnlySpan name, System.ReadOnlySpan value); + void OnHeadersComplete(bool endStream); + } public partial interface IHttpRequestLineHandler { void OnStartLine(Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod method, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpVersion version, System.Span target, System.Span path, System.Span query, System.Span customMethod, bool pathEncoded); diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs index db62037f74..6d02b95728 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs @@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http { - internal class HttpParser : IHttpParser where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler + public class HttpParser : IHttpParser where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler { private readonly bool _showErrorDetails; diff --git a/src/Servers/Kestrel/Core/src/Internal/Http3/QPack/QPackDecoder.cs b/src/Servers/Kestrel/Core/src/Internal/Http3/QPack/QPackDecoder.cs index a52ad04e81..538a9ff2fc 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http3/QPack/QPackDecoder.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http3/QPack/QPackDecoder.cs @@ -3,8 +3,8 @@ using System; using System.Buffers; -using System.Net.Http; using System.Net.Http.HPack; +using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3.QPack { diff --git a/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj b/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj index fc50e5df73..37d8684e99 100644 --- a/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj +++ b/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj @@ -9,6 +9,7 @@ true CS1591;$(NoWarn) false + $(DefineConstants);KESTREL diff --git a/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj b/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj index 209b20b11e..32d1139d42 100644 --- a/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj +++ b/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj @@ -4,6 +4,7 @@ $(DefaultNetCoreTargetFramework) true Kestrel.Core.Tests + $(DefineConstants);KESTREL diff --git a/src/Shared/Http2/Hpack/HPackDecoder.cs b/src/Shared/Http2/Hpack/HPackDecoder.cs index 19e6f34898..93c4bfeb9e 100644 --- a/src/Shared/Http2/Hpack/HPackDecoder.cs +++ b/src/Shared/Http2/Hpack/HPackDecoder.cs @@ -4,6 +4,9 @@ using System.Buffers; using System.Diagnostics; +#if KESTREL +using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; +#endif namespace System.Net.Http.HPack { diff --git a/src/Shared/Http2/IHttpHeadersHandler.cs b/src/Shared/Http2/IHttpHeadersHandler.cs index f86dc9ff7a..256dde1797 100644 --- a/src/Shared/Http2/IHttpHeadersHandler.cs +++ b/src/Shared/Http2/IHttpHeadersHandler.cs @@ -2,11 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if KESTREL +using System; + +namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http +#else namespace System.Net.Http +#endif { - internal interface IHttpHeadersHandler +#if KESTREL + public +#else + internal +#endif + interface IHttpHeadersHandler { void OnHeader(ReadOnlySpan name, ReadOnlySpan value); void OnHeadersComplete(bool endStream); } -} \ No newline at end of file +} diff --git a/src/Shared/test/Shared.Tests/Http2/HPackDecoderTest.cs b/src/Shared/test/Shared.Tests/Http2/HPackDecoderTest.cs index 01dd76c88b..9e80a509b7 100644 --- a/src/Shared/test/Shared.Tests/Http2/HPackDecoderTest.cs +++ b/src/Shared/test/Shared.Tests/Http2/HPackDecoderTest.cs @@ -8,6 +8,9 @@ using System.Collections.Generic; using System.Text; using System.Net.Http.HPack; using Xunit; +#if KESTREL +using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; +#endif namespace System.Net.Http.Unit.Tests.HPack {