Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit 0cf53e7

Browse files
committed
Show HTTP/2 status on requests #106
1 parent 047e39e commit 0cf53e7

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

shared/Microsoft.AspNetCore.HttpSys.Sources/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ internal static class Constants
1717

1818
internal static Version V1_0 = new Version(1, 0);
1919
internal static Version V1_1 = new Version(1, 1);
20+
internal static Version V2 = new Version(2, 0);
2021
}
2122
}

shared/Microsoft.AspNetCore.HttpSys.Sources/NativeInterop/HttpApiTypes.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,19 @@ internal struct HTTP_REQUEST_INFO
434434
internal HTTP_REQUEST_AUTH_INFO* pInfo;
435435
}
436436

437+
[Flags]
438+
internal enum HTTP_REQUEST_FLAGS
439+
{
440+
None = 0,
441+
MoreEntityBodyExists = 1,
442+
IPRouted = 2,
443+
Http2 = 4,
444+
}
445+
437446
[StructLayout(LayoutKind.Sequential)]
438447
internal struct HTTP_REQUEST
439448
{
440-
internal uint Flags;
449+
internal HTTP_REQUEST_FLAGS Flags;
441450
internal ulong ConnectionId;
442451
internal ulong RequestId;
443452
internal ulong UrlContext;

shared/Microsoft.AspNetCore.HttpSys.Sources/RequestProcessing/NativeRequestContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ internal SslStatus SslStatus
8888
}
8989
}
9090

91+
internal bool IsHttp2 => NativeRequest->Flags.HasFlag(HttpApiTypes.HTTP_REQUEST_FLAGS.Http2);
92+
9193
internal uint Size
9294
{
9395
get { return (uint)_backingBuffer.Length - AlignmentPadding; }
@@ -156,6 +158,10 @@ internal CookedUrl GetCookedUrl()
156158

157159
internal Version GetVersion()
158160
{
161+
if (IsHttp2)
162+
{
163+
return Constants.V2;
164+
}
159165
var major = NativeRequest->Version.MajorVersion;
160166
var minor = NativeRequest->Version.MinorVersion;
161167
if (major == 1 && minor == 1)

src/Microsoft.AspNetCore.Server.HttpSys/FeatureContext.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Microsoft.AspNetCore.Http;
1414
using Microsoft.AspNetCore.Http.Features;
1515
using Microsoft.AspNetCore.Http.Features.Authentication;
16+
using Microsoft.AspNetCore.HttpSys.Internal;
1617
using Microsoft.Net.Http.Headers;
1718

1819
namespace Microsoft.AspNetCore.Server.HttpSys
@@ -168,11 +169,15 @@ string IHttpRequestFeature.Protocol
168169
if (IsNotInitialized(Fields.Protocol))
169170
{
170171
var protocol = Request.ProtocolVersion;
171-
if (protocol.Major == 1 && protocol.Minor == 1)
172+
if (protocol == Constants.V2)
173+
{
174+
_httpProtocolVersion = "HTTP/2";
175+
}
176+
else if (protocol == Constants.V1_1)
172177
{
173178
_httpProtocolVersion = "HTTP/1.1";
174179
}
175-
else if (protocol.Major == 1 && protocol.Minor == 0)
180+
else if (protocol == Constants.V1_0)
176181
{
177182
_httpProtocolVersion = "HTTP/1.0";
178183
}

0 commit comments

Comments
 (0)