Pubternal IHttpHeadersHandler (#17573)

This commit is contained in:
Chris Ross 2019-12-04 09:40:17 -08:00 committed by GitHub
parent 3b7cdc166a
commit bd7c89aa20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 4 deletions

View File

@ -214,6 +214,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
Custom = (byte)9,
None = (byte)255,
}
public partial class HttpParser<TRequestHandler> 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<byte> reader) { throw null; }
public bool ParseRequestLine(TRequestHandler handler, in System.Buffers.ReadOnlySequence<byte> 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<byte> name, System.ReadOnlySpan<byte> 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<byte> target, System.Span<byte> path, System.Span<byte> query, System.Span<byte> customMethod, bool pathEncoded);

View File

@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
internal class HttpParser<TRequestHandler> : IHttpParser<TRequestHandler> where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler
public class HttpParser<TRequestHandler> : IHttpParser<TRequestHandler> where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler
{
private readonly bool _showErrorDetails;

View File

@ -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
{

View File

@ -9,6 +9,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>CS1591;$(NoWarn)</NoWarn>
<IsShippingPackage>false</IsShippingPackage>
<DefineConstants>$(DefineConstants);KESTREL</DefineConstants>
</PropertyGroup>
<ItemGroup>

View File

@ -4,6 +4,7 @@
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TestGroupName>Kestrel.Core.Tests</TestGroupName>
<DefineConstants>$(DefineConstants);KESTREL</DefineConstants>
</PropertyGroup>
<ItemGroup>

View File

@ -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
{

View File

@ -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<byte> name, ReadOnlySpan<byte> value);
void OnHeadersComplete(bool endStream);
}
}
}

View File

@ -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
{