Merge branch 'release/2.2'

This commit is contained in:
Chris Ross (ASP.NET) 2018-09-06 15:25:03 -07:00
commit aea71d47e2
5 changed files with 25 additions and 4 deletions

View File

@ -20,6 +20,6 @@
<XunitPackageVersion>2.3.1</XunitPackageVersion> <XunitPackageVersion>2.3.1</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.4.0</XunitRunnerVisualStudioPackageVersion> <XunitRunnerVisualStudioPackageVersion>2.4.0</XunitRunnerVisualStudioPackageVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Package Versions: Pinned" />
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " /> <Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
<PropertyGroup Label="Package Versions: Pinned" />
</Project> </Project>

View File

@ -17,5 +17,6 @@ namespace Microsoft.AspNetCore.HttpSys.Internal
internal static Version V1_0 = new Version(1, 0); internal static Version V1_0 = new Version(1, 0);
internal static Version V1_1 = new Version(1, 1); internal static Version V1_1 = new Version(1, 1);
internal static Version V2 = new Version(2, 0);
} }
} }

View File

@ -434,10 +434,19 @@ namespace Microsoft.AspNetCore.HttpSys.Internal
internal HTTP_REQUEST_AUTH_INFO* pInfo; internal HTTP_REQUEST_AUTH_INFO* pInfo;
} }
[Flags]
internal enum HTTP_REQUEST_FLAGS
{
None = 0,
MoreEntityBodyExists = 1,
IPRouted = 2,
Http2 = 4,
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct HTTP_REQUEST internal struct HTTP_REQUEST
{ {
internal uint Flags; internal HTTP_REQUEST_FLAGS Flags;
internal ulong ConnectionId; internal ulong ConnectionId;
internal ulong RequestId; internal ulong RequestId;
internal ulong UrlContext; internal ulong UrlContext;

View File

@ -88,6 +88,8 @@ namespace Microsoft.AspNetCore.HttpSys.Internal
} }
} }
internal bool IsHttp2 => NativeRequest->Flags.HasFlag(HttpApiTypes.HTTP_REQUEST_FLAGS.Http2);
internal uint Size internal uint Size
{ {
get { return (uint)_backingBuffer.Length - AlignmentPadding; } get { return (uint)_backingBuffer.Length - AlignmentPadding; }
@ -156,6 +158,10 @@ namespace Microsoft.AspNetCore.HttpSys.Internal
internal Version GetVersion() internal Version GetVersion()
{ {
if (IsHttp2)
{
return Constants.V2;
}
var major = NativeRequest->Version.MajorVersion; var major = NativeRequest->Version.MajorVersion;
var minor = NativeRequest->Version.MinorVersion; var minor = NativeRequest->Version.MinorVersion;
if (major == 1 && minor == 1) if (major == 1 && minor == 1)

View File

@ -13,6 +13,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.AspNetCore.HttpSys.Internal;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Server.HttpSys namespace Microsoft.AspNetCore.Server.HttpSys
@ -168,11 +169,15 @@ namespace Microsoft.AspNetCore.Server.HttpSys
if (IsNotInitialized(Fields.Protocol)) if (IsNotInitialized(Fields.Protocol))
{ {
var protocol = Request.ProtocolVersion; var protocol = Request.ProtocolVersion;
if (protocol.Major == 1 && protocol.Minor == 1) if (protocol == Constants.V2)
{
_httpProtocolVersion = "HTTP/2";
}
else if (protocol == Constants.V1_1)
{ {
_httpProtocolVersion = "HTTP/1.1"; _httpProtocolVersion = "HTTP/1.1";
} }
else if (protocol.Major == 1 && protocol.Minor == 0) else if (protocol == Constants.V1_0)
{ {
_httpProtocolVersion = "HTTP/1.0"; _httpProtocolVersion = "HTTP/1.0";
} }