Skip to content

Commit 8471fe3

Browse files
committed
HttpSys GoAway #13356
1 parent 3a07534 commit 8471fe3

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

src/Servers/HttpSys/samples/SelfHostServer/SelfHostServer.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
55
<OutputType>Exe</OutputType>
66
<ServerGarbageCollection>true</ServerGarbageCollection>
77
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<!--Imitate IIS Express so we can use it's cert bindings-->
11+
<PackageTags>214124cd-d05b-4309-9af9-9caa44b2b74a</PackageTags>
12+
</PropertyGroup>
813

914
<ItemGroup>
1015
<Reference Include="Microsoft.AspNetCore.Server.HttpSys" />

src/Servers/HttpSys/samples/SelfHostServer/Startup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public static void Main(string[] args)
3737
.UseHttpSys(options =>
3838
{
3939
options.UrlPrefixes.Add("http://localhost:5000");
40+
// This is a pre-configured IIS express port. See the PackageTags in the csproj.
41+
options.UrlPrefixes.Add("https://localhost:44319");
4042
options.Authentication.Schemes = AuthenticationSchemes.None;
4143
options.Authentication.AllowAnonymous = true;
4244
})

src/Servers/HttpSys/src/NativeInterop/ComNetOS.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using Microsoft.Extensions.Internal;
65

76
namespace Microsoft.AspNetCore.Server.HttpSys
87
{
@@ -12,11 +11,18 @@ internal static class ComNetOS
1211
// Minimum support for Windows 7 is assumed.
1312
internal static readonly bool IsWin8orLater;
1413

14+
public static bool SupportsGoAway { get; }
15+
1516
static ComNetOS()
1617
{
1718
var win8Version = new Version(6, 2);
1819

1920
IsWin8orLater = (Environment.OSVersion.Version >= win8Version);
21+
22+
var win1019H2Version = new Version(10, 0, 18363);
23+
// Win10 1909 (19H2) or later
24+
SupportsGoAway = (Environment.OSVersion.Version >= win1019H2Version);
2025
}
26+
2127
}
2228
}

src/Servers/HttpSys/src/RequestProcessing/Response.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Diagnostics;
7-
using System.Globalization;
87
using System.IO;
98
using System.Runtime.InteropServices;
109
using System.Threading;
@@ -417,6 +416,10 @@ internal HttpApiTypes.HTTP_FLAGS ComputeHeaders(long writeCount, bool endOfReque
417416
Headers.Append(HttpKnownHeaderNames.Connection, Constants.Close);
418417
}
419418
flags = HttpApiTypes.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_DISCONNECT;
419+
if (responseCloseSet && requestVersion >= Constants.V2 && ComNetOS.SupportsGoAway)
420+
{
421+
flags |= HttpApiTypes.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_GOAWAY;
422+
}
420423
}
421424

422425
Headers.IsReadOnly = true;

src/Shared/HttpSys/NativeInterop/HttpApiTypes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ internal enum HTTP_FLAGS : uint
602602
HTTP_INITIALIZE_SERVER = 0x00000001,
603603
HTTP_INITIALIZE_CBT = 0x00000004,
604604
HTTP_SEND_RESPONSE_FLAG_OPAQUE = 0x00000040,
605+
HTTP_SEND_RESPONSE_FLAG_GOAWAY = 0x00000100,
605606
}
606607

607608
[Flags]

0 commit comments

Comments
 (0)