Merge remote-tracking branch 'origin/release/2.1' into dev
This commit is contained in:
commit
d5763f5628
|
|
@ -72,6 +72,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AspNetCoreModuleTests", "test\AspNetCoreModuleTests\AspNetCoreModuleTests.vcxproj", "{0692D963-DB10-4387-B3EA-460FBB9BD9A3}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AspNetCoreModuleTests", "test\AspNetCoreModuleTests\AspNetCoreModuleTests.vcxproj", "{0692D963-DB10-4387-B3EA-460FBB9BD9A3}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ANCMStressTestApp", "test\ANCMStressTestApp\ANCMStressTestApp.csproj", "{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestTasks", "test\TestTasks\TestTasks.csproj", "{064D860B-4D7C-4B1D-918F-E020F1B99E2A}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -228,6 +232,30 @@ Global
|
||||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x64.Build.0 = Release|x64
|
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x64.Build.0 = Release|x64
|
||||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.ActiveCfg = Release|Win32
|
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.Build.0 = Release|Win32
|
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -246,6 +274,8 @@ Global
|
||||||
{D57EA297-6DC2-4BC0-8C91-334863327863} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
|
{D57EA297-6DC2-4BC0-8C91-334863327863} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
|
||||||
{46A8612B-418B-4D70-B3A7-A21DD0627473} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
|
{46A8612B-418B-4D70-B3A7-A21DD0627473} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
|
||||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
|
{0692D963-DB10-4387-B3EA-460FBB9BD9A3} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
|
||||||
|
{13FD8F12-FFBE-4D01-B4AC-444F2994B04F} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
|
||||||
|
{064D860B-4D7C-4B1D-918F-E020F1B99E2A} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {DB4F868D-E1AE-4FD7-9333-69FA15B268C5}
|
SolutionGuid = {DB4F868D-E1AE-4FD7-9333-69FA15B268C5}
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@
|
||||||
<SystemIOPipelinesPackageVersion>4.5.0-preview2-26313-01</SystemIOPipelinesPackageVersion>
|
<SystemIOPipelinesPackageVersion>4.5.0-preview2-26313-01</SystemIOPipelinesPackageVersion>
|
||||||
<SystemManagementAutomationPackageVersion>6.1.7601.17515</SystemManagementAutomationPackageVersion>
|
<SystemManagementAutomationPackageVersion>6.1.7601.17515</SystemManagementAutomationPackageVersion>
|
||||||
<SystemMemoryPackageVersion>4.5.0-preview2-26313-01</SystemMemoryPackageVersion>
|
<SystemMemoryPackageVersion>4.5.0-preview2-26313-01</SystemMemoryPackageVersion>
|
||||||
|
<SystemNetWebSocketsWebSocketProtocolPackageVersion>4.5.0-preview2-26313-01</SystemNetWebSocketsWebSocketProtocolPackageVersion>
|
||||||
<SystemNumericsVectorsPackageVersion>4.5.0-preview2-26313-01</SystemNumericsVectorsPackageVersion>
|
<SystemNumericsVectorsPackageVersion>4.5.0-preview2-26313-01</SystemNumericsVectorsPackageVersion>
|
||||||
<SystemRuntimeCompilerServicesUnsafePackageVersion>4.5.0-preview2-26313-01</SystemRuntimeCompilerServicesUnsafePackageVersion>
|
<SystemRuntimeCompilerServicesUnsafePackageVersion>4.5.0-preview2-26313-01</SystemRuntimeCompilerServicesUnsafePackageVersion>
|
||||||
<SystemSecurityPrincipalWindowsPackageVersion>4.5.0-preview2-26313-01</SystemSecurityPrincipalWindowsPackageVersion>
|
<SystemSecurityPrincipalWindowsPackageVersion>4.5.0-preview2-26313-01</SystemSecurityPrincipalWindowsPackageVersion>
|
||||||
|
<Tooling_NewtonsoftJsonPackageVersion>9.0.1</Tooling_NewtonsoftJsonPackageVersion>
|
||||||
<XunitPackageVersion>2.3.1</XunitPackageVersion>
|
<XunitPackageVersion>2.3.1</XunitPackageVersion>
|
||||||
<XunitRunnerVisualStudioPackageVersion>2.4.0-beta.1.build3945</XunitRunnerVisualStudioPackageVersion>
|
<XunitRunnerVisualStudioPackageVersion>2.4.0-beta.1.build3945</XunitRunnerVisualStudioPackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,24 @@
|
||||||
<IISArguments>-h "$(IISAppHostConfig)"</IISArguments>
|
<IISArguments>-h "$(IISAppHostConfig)"</IISArguments>
|
||||||
|
|
||||||
<AncmPath>$(NativePlatform)\aspnetcore.dll</AncmPath>
|
<AncmPath>$(NativePlatform)\aspnetcore.dll</AncmPath>
|
||||||
|
<AncmRHPath>$(NativePlatform)\aspnetcorerh.dll</AncmRHPath>
|
||||||
<DotNetPath>$(userprofile)\.dotnet\$(NativePlatform)\dotnet.exe</DotNetPath>
|
<DotNetPath>$(userprofile)\.dotnet\$(NativePlatform)\dotnet.exe</DotNetPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)..\test\TestTasks\TestTasks.csproj">
|
||||||
|
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<UsingTask TaskName="InjectRequestHandler" AssemblyFile="$(MSBuildThisFileDirectory)..\test\TestTasks\bin\$(Configuration)\netstandard2.0\TestTasks.dll" />
|
||||||
|
|
||||||
|
<Target Name="InjectRequestHandler" AfterTargets="GenerateBuildDependencyFile">
|
||||||
|
<InjectRequestHandler DepsFile="$(ProjectDepsFilePath)" Rid="win7-$(NativePlatform)" LibraryLocation="$(AncmRHPath)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="InjectRequestHandlerOnPublish" AfterTargets="GeneratePublishDependencyFile">
|
||||||
|
<InjectRequestHandler DepsFile="$(PublishDepsFilePath)" Rid="win7-$(NativePlatform)" LibraryLocation="$(AncmRHPath)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,4 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AspNetCoreModuleHostingModel>inprocess</AspNetCoreModuleHostingModel>
|
<AspNetCoreModuleHostingModel>inprocess</AspNetCoreModuleHostingModel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -104,11 +104,7 @@ Finished:
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
STACK_STRU(strEventMsg, 256);
|
STACK_STRU(strEventMsg, 256);
|
||||||
//
|
|
||||||
// Assumption: inprocess application shutdown will be called only at process shutdown
|
|
||||||
// Based on this assumption, we just let shutdown continue and process will exit
|
|
||||||
// Log a warning for ungraceful shutdown
|
|
||||||
//
|
|
||||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||||
ASPNETCORE_EVENT_APP_SHUTDOWN_FAILURE_MSG,
|
ASPNETCORE_EVENT_APP_SHUTDOWN_FAILURE_MSG,
|
||||||
m_pConfig->QueryConfigPath()->QueryStr())))
|
m_pConfig->QueryConfigPath()->QueryStr())))
|
||||||
|
|
@ -118,6 +114,13 @@ Finished:
|
||||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
||||||
strEventMsg.QueryStr());
|
strEventMsg.QueryStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Managed layer may block the shutdown and lead to shutdown timeout
|
||||||
|
// Assumption: only one inprocess application is hosted.
|
||||||
|
// Call process exit to force shutdown
|
||||||
|
//
|
||||||
|
exit(hr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Server.IISIntegration\Microsoft.AspNetCore.Server.IISIntegration.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
|
||||||
|
<PackageReference Include="System.Net.WebSockets.WebSocketProtocol" Version="$(SystemNetWebSocketsWebSocketProtocolPackageVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
|
using Microsoft.AspNetCore.Server.IISIntegration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ANCMStressTestApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var host = new WebHostBuilder()
|
||||||
|
.ConfigureLogging((_, factory) =>
|
||||||
|
{
|
||||||
|
factory.AddConsole();
|
||||||
|
})
|
||||||
|
.UseKestrel()
|
||||||
|
.UseIISIntegration()
|
||||||
|
.UseStartup<Startup>()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
host.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:16606/",
|
||||||
|
"sslPort": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ANCMStressTestSample": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"applicationUrl": "http://localhost:16607/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,231 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net.WebSockets;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
|
using Microsoft.Net.Http.Headers;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
|
namespace ANCMStressTestApp
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configure(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Map("/HelloWorld", HelloWorld);
|
||||||
|
app.Map("/ConnectionClose", ConnectionClose);
|
||||||
|
app.Map("/EchoPostData", EchoPostData);
|
||||||
|
app.Map("/LargeResponseBody", LargeResponseBody);
|
||||||
|
app.Map("/ResponseHeaders", ResponseHeaders);
|
||||||
|
app.Map("/EnvironmentVariables", EnvironmentVariables);
|
||||||
|
app.Map("/RequestInformation", RequestInformation);
|
||||||
|
app.Map("/WebSocket", WebSocket);
|
||||||
|
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync("Default Page");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HelloWorld(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync("Hello World");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConnectionClose(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
context.Response.Headers[HeaderNames.Connection] = "close";
|
||||||
|
await context.Response.WriteAsync("Connnection Close");
|
||||||
|
await context.Response.Body.FlushAsync();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EchoPostData(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
string responseBody = string.Empty;
|
||||||
|
|
||||||
|
if (string.Equals(context.Request.Method, "POST", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(context.Request.Body, Encoding.UTF8))
|
||||||
|
{
|
||||||
|
responseBody = await reader.ReadToEndAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
responseBody = "NoAction";
|
||||||
|
}
|
||||||
|
|
||||||
|
await context.Response.WriteAsync(responseBody);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LargeResponseBody(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
if (int.TryParse(context.Request.Query["length"], out var length))
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync(new string('a', length));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResponseHeaders(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
context.Response.Headers["UnknownHeader"] = "test123=foo";
|
||||||
|
context.Response.ContentType = "text/plain";
|
||||||
|
context.Response.Headers["MultiHeader"] = new StringValues(new string[] { "1", "2" });
|
||||||
|
await context.Response.WriteAsync("Request Complete");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnvironmentVariables(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
context.Response.ContentType = "text/plain";
|
||||||
|
await context.Response.WriteAsync("Environment Variables:" + Environment.NewLine);
|
||||||
|
var vars = Environment.GetEnvironmentVariables();
|
||||||
|
foreach (var key in vars.Keys.Cast<string>().OrderBy(key => key, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var value = vars[key];
|
||||||
|
await context.Response.WriteAsync(key + ": " + value + Environment.NewLine);
|
||||||
|
}
|
||||||
|
await context.Response.WriteAsync(Environment.NewLine);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RequestInformation(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
context.Response.ContentType = "text/plain";
|
||||||
|
|
||||||
|
await context.Response.WriteAsync("Address:" + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("Scheme: " + context.Request.Scheme + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("Host: " + context.Request.Headers["Host"] + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("PathBase: " + context.Request.PathBase.Value + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("Path: " + context.Request.Path.Value + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("Query: " + context.Request.QueryString.Value + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync(Environment.NewLine);
|
||||||
|
|
||||||
|
await context.Response.WriteAsync("Connection:" + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("RemoteIp: " + context.Connection.RemoteIpAddress + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("RemotePort: " + context.Connection.RemotePort + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("LocalIp: " + context.Connection.LocalIpAddress + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync("LocalPort: " + context.Connection.LocalPort + Environment.NewLine);
|
||||||
|
await context.Response.WriteAsync(Environment.NewLine);
|
||||||
|
|
||||||
|
await context.Response.WriteAsync("Headers:" + Environment.NewLine);
|
||||||
|
foreach (var header in context.Request.Headers)
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync(header.Key + ": " + header.Value + Environment.NewLine);
|
||||||
|
}
|
||||||
|
await context.Response.WriteAsync(Environment.NewLine);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WebSocket(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
var upgradeFeature = context.Features.Get<IHttpUpgradeFeature>();
|
||||||
|
|
||||||
|
// Generate WebSocket response headers
|
||||||
|
string key = context.Request.Headers[Constants.Headers.SecWebSocketKey].ToString();
|
||||||
|
var responseHeaders = HandshakeHelpers.GenerateResponseHeaders(key);
|
||||||
|
foreach (var headerPair in responseHeaders)
|
||||||
|
{
|
||||||
|
context.Response.Headers[headerPair.Key] = headerPair.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upgrade the connection
|
||||||
|
Stream opaqueTransport = await upgradeFeature.UpgradeAsync();
|
||||||
|
|
||||||
|
// Get the WebSocket object
|
||||||
|
var ws = WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: null, keepAliveInterval: TimeSpan.FromMinutes(2));
|
||||||
|
|
||||||
|
var appLifetime = app.ApplicationServices.GetRequiredService<IApplicationLifetime>();
|
||||||
|
|
||||||
|
await Echo(ws, appLifetime.ApplicationStopping);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Echo(WebSocket webSocket, CancellationToken token)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var buffer = new byte[1024 * 4];
|
||||||
|
var result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), token);
|
||||||
|
bool closeFromServer = false;
|
||||||
|
string closeFromServerCmd = "CloseFromServer";
|
||||||
|
int closeFromServerLength = closeFromServerCmd.Length;
|
||||||
|
|
||||||
|
while (!result.CloseStatus.HasValue && !token.IsCancellationRequested && !closeFromServer)
|
||||||
|
{
|
||||||
|
if (result.Count == closeFromServerLength &&
|
||||||
|
Encoding.ASCII.GetString(buffer).Substring(0, result.Count) == closeFromServerCmd)
|
||||||
|
{
|
||||||
|
// The client sent "CloseFromServer" text message to request the server to close (a test scenario).
|
||||||
|
closeFromServer = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, token);
|
||||||
|
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.CloseStatus.HasValue)
|
||||||
|
{
|
||||||
|
// Client-initiated close handshake
|
||||||
|
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Server-initiated close handshake due to either of the two conditions:
|
||||||
|
// (1) The applicaton host is performing a graceful shutdown.
|
||||||
|
// (2) The client sent "CloseFromServer" text message to request the server to close (a test scenario).
|
||||||
|
await webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, closeFromServerCmd, CancellationToken.None);
|
||||||
|
|
||||||
|
// The server has sent the Close frame.
|
||||||
|
// Stop sending but keep receiving until we get the Close frame from the client.
|
||||||
|
while (!result.CloseStatus.HasValue)
|
||||||
|
{
|
||||||
|
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("{0} Exception caught!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
namespace ANCMStressTestApp
|
||||||
|
{
|
||||||
|
public static class Constants
|
||||||
|
{
|
||||||
|
public static class Headers
|
||||||
|
{
|
||||||
|
public const string Upgrade = "Upgrade";
|
||||||
|
public const string UpgradeWebSocket = "websocket";
|
||||||
|
public const string Connection = "Connection";
|
||||||
|
public const string SecWebSocketKey = "Sec-WebSocket-Key";
|
||||||
|
public const string SecWebSocketAccept = "Sec-WebSocket-Accept";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ANCMStressTestApp
|
||||||
|
{
|
||||||
|
// Removed all the
|
||||||
|
internal static class HandshakeHelpers
|
||||||
|
{
|
||||||
|
public static IEnumerable<KeyValuePair<string, string>> GenerateResponseHeaders(string key)
|
||||||
|
{
|
||||||
|
yield return new KeyValuePair<string, string>(Constants.Headers.Connection, Constants.Headers.Upgrade);
|
||||||
|
yield return new KeyValuePair<string, string>(Constants.Headers.Upgrade, Constants.Headers.UpgradeWebSocket);
|
||||||
|
yield return new KeyValuePair<string, string>(Constants.Headers.SecWebSocketAccept, CreateResponseKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string CreateResponseKey(string requestKey)
|
||||||
|
{
|
||||||
|
// "The value of this header field is constructed by concatenating /key/, defined above in step 4
|
||||||
|
// in Section 4.2.2, with the string "258EAFA5- E914-47DA-95CA-C5AB0DC85B11", taking the SHA-1 hash of
|
||||||
|
// this concatenated value to obtain a 20-byte value and base64-encoding"
|
||||||
|
// https://tools.ietf.org/html/rfc6455#section-4.2.2
|
||||||
|
|
||||||
|
if (requestKey == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(requestKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var algorithm = SHA1.Create())
|
||||||
|
{
|
||||||
|
string merged = requestKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
|
byte[] mergedBytes = Encoding.UTF8.GetBytes(merged);
|
||||||
|
byte[] hashedBytes = algorithm.ComputeHash(mergedBytes);
|
||||||
|
return Convert.ToBase64String(hashedBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace TestTasks
|
||||||
|
{
|
||||||
|
public class InjectRequestHandler : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string DepsFile { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Rid { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string LibraryLocation { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
InjectNativeLibrary(DepsFile);
|
||||||
|
|
||||||
|
// Parse input
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InjectNativeLibrary(string depsFile)
|
||||||
|
{
|
||||||
|
JToken deps;
|
||||||
|
using (var file = File.OpenText(depsFile))
|
||||||
|
using (JsonTextReader reader = new JsonTextReader(file))
|
||||||
|
{
|
||||||
|
deps = JObject.ReadFrom(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
var libraryName = "ANCMRH/1.0";
|
||||||
|
var libraries = (JObject)deps["libraries"];
|
||||||
|
|
||||||
|
var target = (JObject)((JObject)deps["targets"]).Properties().First().Value;
|
||||||
|
var targetLibrary = target.Properties().FirstOrDefault(p => p.Name == libraryName);
|
||||||
|
targetLibrary?.Remove();
|
||||||
|
targetLibrary =
|
||||||
|
new JProperty(libraryName, new JObject(
|
||||||
|
new JProperty("runtimeTargets", new JObject(
|
||||||
|
new JProperty(LibraryLocation.Replace('\\', '/'), new JObject(
|
||||||
|
new JProperty("rid", Rid),
|
||||||
|
new JProperty("assetType", "native")
|
||||||
|
))))));
|
||||||
|
target.AddFirst(targetLibrary);
|
||||||
|
|
||||||
|
var library = libraries.Properties().FirstOrDefault(p => p.Name == libraryName);
|
||||||
|
library?.Remove();
|
||||||
|
library =
|
||||||
|
new JProperty(libraryName, new JObject(
|
||||||
|
new JProperty("type", "package"),
|
||||||
|
new JProperty("serviceable", true),
|
||||||
|
new JProperty("sha512", ""),
|
||||||
|
new JProperty("path", libraryName),
|
||||||
|
new JProperty("hashPath", "")));
|
||||||
|
libraries.AddFirst(library);
|
||||||
|
|
||||||
|
using (var file = File.CreateText(depsFile))
|
||||||
|
using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented })
|
||||||
|
{
|
||||||
|
deps.WriteTo(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="$(Tooling_NewtonsoftJsonPackageVersion)" />
|
||||||
|
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkPackageVersion)" />
|
||||||
|
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCorePackageVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Loading…
Reference in New Issue