Skip to content

Commit bd7c89a

Browse files
authored
Pubternal IHttpHeadersHandler (#17573)
1 parent 3b7cdc1 commit bd7c89a

File tree

8 files changed

+35
-4
lines changed

8 files changed

+35
-4
lines changed

src/Servers/Kestrel/Core/ref/Microsoft.AspNetCore.Server.Kestrel.Core.netcoreapp.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ public enum HttpMethod : byte
214214
Custom = (byte)9,
215215
None = (byte)255,
216216
}
217+
public partial class HttpParser<TRequestHandler> where TRequestHandler : Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.IHttpHeadersHandler, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.IHttpRequestLineHandler
218+
{
219+
public HttpParser() { }
220+
public HttpParser(bool showErrorDetails) { }
221+
public bool ParseHeaders(TRequestHandler handler, ref System.Buffers.SequenceReader<byte> reader) { throw null; }
222+
public bool ParseRequestLine(TRequestHandler handler, in System.Buffers.ReadOnlySequence<byte> buffer, out System.SequencePosition consumed, out System.SequencePosition examined) { throw null; }
223+
}
217224
public enum HttpScheme
218225
{
219226
Unknown = -1,
@@ -228,6 +235,11 @@ public enum HttpVersion
228235
Http2 = 2,
229236
Http3 = 3,
230237
}
238+
public partial interface IHttpHeadersHandler
239+
{
240+
void OnHeader(System.ReadOnlySpan<byte> name, System.ReadOnlySpan<byte> value);
241+
void OnHeadersComplete(bool endStream);
242+
}
231243
public partial interface IHttpRequestLineHandler
232244
{
233245
void OnStartLine(Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod method, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpVersion version, System.Span<byte> target, System.Span<byte> path, System.Span<byte> query, System.Span<byte> customMethod, bool pathEncoded);

src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
1313
{
14-
internal class HttpParser<TRequestHandler> : IHttpParser<TRequestHandler> where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler
14+
public class HttpParser<TRequestHandler> : IHttpParser<TRequestHandler> where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler
1515
{
1616
private readonly bool _showErrorDetails;
1717

src/Servers/Kestrel/Core/src/Internal/Http3/QPack/QPackDecoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
using System;
55
using System.Buffers;
6-
using System.Net.Http;
76
using System.Net.Http.HPack;
7+
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
88

99
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3.QPack
1010
{

src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1010
<NoWarn>CS1591;$(NoWarn)</NoWarn>
1111
<IsShippingPackage>false</IsShippingPackage>
12+
<DefineConstants>$(DefineConstants);KESTREL</DefineConstants>
1213
</PropertyGroup>
1314

1415
<ItemGroup>

src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<TestGroupName>Kestrel.Core.Tests</TestGroupName>
7+
<DefineConstants>$(DefineConstants);KESTREL</DefineConstants>
78
</PropertyGroup>
89

910
<ItemGroup>

src/Shared/Http2/Hpack/HPackDecoder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
using System.Buffers;
66
using System.Diagnostics;
7+
#if KESTREL
8+
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
9+
#endif
710

811
namespace System.Net.Http.HPack
912
{

src/Shared/Http2/IHttpHeadersHandler.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#if KESTREL
6+
using System;
7+
8+
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
9+
#else
510
namespace System.Net.Http
11+
#endif
612
{
7-
internal interface IHttpHeadersHandler
13+
#if KESTREL
14+
public
15+
#else
16+
internal
17+
#endif
18+
interface IHttpHeadersHandler
819
{
920
void OnHeader(ReadOnlySpan<byte> name, ReadOnlySpan<byte> value);
1021
void OnHeadersComplete(bool endStream);
1122
}
12-
}
23+
}

src/Shared/test/Shared.Tests/Http2/HPackDecoderTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
using System.Text;
99
using System.Net.Http.HPack;
1010
using Xunit;
11+
#if KESTREL
12+
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
13+
#endif
1114

1215
namespace System.Net.Http.Unit.Tests.HPack
1316
{

0 commit comments

Comments
 (0)