Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross target .NET 5.0 and 3.1 #168

Merged
merged 4 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
"dotnet": "5.0.100-preview.5.20251.2",
"runtimes": {
"dotnet/x64": [
"$(MicrosoftNETCoreAppPackageVersion)"
"$(MicrosoftNETCoreAppPackageVersion)",
"3.1.0"
],
"dotnet/x86": [
"$(MicrosoftNETCoreAppPackageVersion)"
"$(MicrosoftNETCoreAppPackageVersion)",
"3.1.0"
],
"aspnetcore/x64": [
"3.1.0"
],
"aspnetcore/x86": [
"3.1.0"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion samples/BenchmarkApp/BenchmarkApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework>
<TargetFrameworks>netcoreapp5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 4 additions & 9 deletions samples/ReverseProxy.Sample/ReverseProxy.Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework>
<TargetFrameworks>netcoreapp5.0;netcoreapp3.1</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.ReverseProxy.Sample</RootNamespace>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)"/>
<InternalsVisibleTo Include="ReverseProxy.Sample.Tests"/>
<ProjectReference Include="..\..\src\ReverseProxy\Microsoft.ReverseProxy.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\ReverseProxy\Microsoft.ReverseProxy.csproj"/>
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\"/>
<Folder Include="Properties\" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/ReverseProxy/Microsoft.ReverseProxy.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework>
<TargetFrameworks>netcoreapp5.0;netcoreapp3.1</TargetFrameworks>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.ReverseProxy</RootNamespace>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/ReverseProxy/Service/Proxy/HttpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ private async Task NormalProxyAsync(

// :::::::::::::::::::::::::::::::::::::::::::::
// :: Step 0: Disable ASP .NET Core limits for streaming requests
var isIncomingHttp2 = HttpProtocol.IsHttp2(context.Request.Protocol);
var isIncomingHttp2 = ProtocolHelper.IsHttp2(context.Request.Protocol);

// NOTE: We heuristically assume gRPC-looking requests may require streaming semantics.
// See https://github.com/microsoft/reverse-proxy/issues/118 for design discussion.
var isStreamingRequest = isIncomingHttp2 && GrpcProtocolHelper.IsGrpcContentType(context.Request.ContentType);
var isStreamingRequest = isIncomingHttp2 && ProtocolHelper.IsGrpcContentType(context.Request.ContentType);
if (isStreamingRequest)
{
DisableMinRequestBodyDataRateAndMaxRequestBodySize(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@

namespace Microsoft.ReverseProxy
{
internal static class GrpcProtocolHelper
internal static class ProtocolHelper
{
internal const string GrpcContentType = "application/grpc";

public static bool IsHttp2(string protocol)
{
#if NETCOREAPP5_0
return Microsoft.AspNetCore.Http.HttpProtocol.IsHttp2(protocol);
#elif NETCOREAPP3_1
return StringComparer.OrdinalIgnoreCase.Equals("HTTP/2", protocol);
#else
#error A target framework was added to the project and needs to be added to this condition.
#endif
}

// NOTE: When https://github.com/dotnet/aspnetcore/issues/21265 is addressed,
// this can be replaced with `MediaTypeHeaderValue.IsSubsetOf(...)`.
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework>
<TargetFrameworks>netcoreapp5.0;netcoreapp3.1</TargetFrameworks>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.ReverseProxy</RootNamespace>
</PropertyGroup>
Expand Down