Cross-compile Response Compression
- GZipStream is not flushable on .NET Framework
This commit is contained in:
Родитель
565b94e3af
Коммит
8b506cf36c
|
@ -15,4 +15,8 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -15,4 +15,8 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -20,4 +20,8 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -16,4 +16,8 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -37,7 +37,13 @@ namespace Microsoft.AspNetCore.ResponseCompression
|
|||
{
|
||||
get
|
||||
{
|
||||
#if NET461
|
||||
return false;
|
||||
#elif NETSTANDARD2_0
|
||||
return true;
|
||||
#else
|
||||
#error target frameworks need to be updated
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<PropertyGroup>
|
||||
<VersionPrefix>2.0.0</VersionPrefix>
|
||||
<Description>ASP.NET Core middleware for HTTP Response compression.</Description>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>aspnetcore</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -505,9 +505,16 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
|
|||
|
||||
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
|
||||
|
||||
#if NET461 // Flush not supported, compression disabled
|
||||
Assert.NotNull(response.Content.Headers.GetValues(HeaderNames.ContentMD5));
|
||||
Assert.Empty(response.Content.Headers.ContentEncoding);
|
||||
#elif NETCOREAPP2_0 // Flush supported, compression enabled
|
||||
IEnumerable<string> contentMD5 = null;
|
||||
Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out contentMD5));
|
||||
Assert.Single(response.Content.Headers.ContentEncoding, "gzip");
|
||||
#else
|
||||
#error Target frameworks need to be updated.
|
||||
#endif
|
||||
|
||||
var body = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
|
@ -563,9 +570,16 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
|
|||
|
||||
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
|
||||
|
||||
#if NET461 // Flush not supported, compression disabled
|
||||
Assert.NotNull(response.Content.Headers.GetValues(HeaderNames.ContentMD5));
|
||||
Assert.Empty(response.Content.Headers.ContentEncoding);
|
||||
#elif NETCOREAPP2_0 // Flush supported, compression enabled
|
||||
IEnumerable<string> contentMD5 = null;
|
||||
Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out contentMD5));
|
||||
Assert.Single(response.Content.Headers.ContentEncoding, "gzip");
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
var body = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче