Skip to content

Commit b7b1a18

Browse files
authored
Remove deflate compression support (#480)
1 parent 05f1e14 commit b7b1a18

File tree

7 files changed

+10
-77
lines changed

7 files changed

+10
-77
lines changed

src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Configure(GrpcServiceOptions options)
3838
if (options._compressionProviders == null || options._compressionProviders.Count == 0)
3939
{
4040
options.CompressionProviders.Add(new GzipCompressionProvider(CompressionLevel.Fastest));
41-
options.CompressionProviders.Add(new DeflateCompressionProvider(CompressionLevel.Fastest));
41+
// deflate is not supported. .NET's DeflateStream does not support RFC1950 - https://github.com/dotnet/corefx/issues/7570
4242
}
4343
}
4444
}

src/Grpc.Net.Client/Internal/GrpcProtocolConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal static class GrpcProtocolConstants
4646
internal static readonly Dictionary<string, ICompressionProvider> DefaultCompressionProviders = new Dictionary<string, ICompressionProvider>(StringComparer.Ordinal)
4747
{
4848
["gzip"] = new GzipCompressionProvider(System.IO.Compression.CompressionLevel.Fastest),
49-
["deflate"] = new DeflateCompressionProvider(System.IO.Compression.CompressionLevel.Fastest)
49+
// deflate is not supported. .NET's DeflateStream does not support RFC1950 - https://github.com/dotnet/corefx/issues/7570
5050
};
5151

5252
internal static readonly string DefaultMessageAcceptEncodingValue;

src/Grpc.Net.Common/Compression/DeflateCompressionProvider.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

test/FunctionalTests/Client/CompressionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class CompressionTests : FunctionalTestBase
3333
{
3434
[TestCase("identity")]
3535
[TestCase("gzip")]
36-
[TestCase("deflate")]
3736
public async Task SendCompressedMessage_ServiceCompressionConfigured_ResponseGzipEncoding(string algorithmName)
3837
{
3938
// Arrange

test/FunctionalTests/Server/CompressionTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ public async Task SendCompressedMessageWithUnsupportedEncoding_ReturnUnimplement
140140
if (writeContext.LoggerName == "SERVER " + typeof(GreeterService).FullName &&
141141
writeContext.EventId.Name == "RpcConnectionError" &&
142142
writeContext.State.ToString() == "Error status code 'Unimplemented' raised." &&
143-
GetRpcExceptionDetail(writeContext.Exception) == "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip, deflate")
143+
GetRpcExceptionDetail(writeContext.Exception) == "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip")
144144
{
145145
return true;
146146
}
147147

148148
if (writeContext.LoggerName == "SERVER " + typeof(GreeterService).FullName &&
149149
writeContext.EventId.Name == "ErrorReadingMessage" &&
150150
writeContext.State.ToString() == "Error reading message." &&
151-
GetRpcExceptionDetail(writeContext.Exception) == "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip, deflate")
151+
GetRpcExceptionDetail(writeContext.Exception) == "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip")
152152
{
153153
return true;
154154
}
@@ -180,9 +180,9 @@ public async Task SendCompressedMessageWithUnsupportedEncoding_ReturnUnimplement
180180

181181
// Assert
182182
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
183-
Assert.AreEqual("identity,gzip,deflate", response.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
183+
Assert.AreEqual("identity,gzip", response.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
184184

185-
response.AssertTrailerStatus(StatusCode.Unimplemented, "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip, deflate");
185+
response.AssertTrailerStatus(StatusCode.Unimplemented, "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip");
186186
}
187187

188188
private class DoesNotExistCompressionProvider : ICompressionProvider

test/Grpc.Net.Client.Tests/AsyncUnaryCallTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task AsyncUnaryCall_Success_HttpRequestMessagePopulated()
6969
Assert.AreEqual(new Uri("https://localhost/ServiceName/MethodName"), httpRequestMessage.RequestUri);
7070
Assert.AreEqual(new MediaTypeHeaderValue("application/grpc"), httpRequestMessage.Content.Headers.ContentType);
7171
Assert.AreEqual(GrpcProtocolConstants.TEHeader, httpRequestMessage.Headers.TE.Single());
72-
Assert.AreEqual("identity,gzip,deflate", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
72+
Assert.AreEqual("identity,gzip", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
7373

7474
var userAgent = httpRequestMessage.Headers.UserAgent.Single();
7575
Assert.AreEqual(GrpcProtocolConstants.UserAgentHeader, userAgent);

test/Grpc.Net.Client.Tests/CompressionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public async Task AsyncUnaryCall_CompressMetadataSentWithRequest_RequestMessageC
143143
Assert.AreEqual("Hello world", response.Message);
144144

145145
Debug.Assert(httpRequestMessage != null);
146-
Assert.AreEqual("identity,gzip,deflate,test", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
146+
Assert.AreEqual("identity,gzip,test", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
147147
Assert.AreEqual("gzip", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageEncodingHeader).Single());
148148
Assert.AreEqual(false, httpRequestMessage.Headers.Contains(GrpcProtocolConstants.CompressionRequestAlgorithmHeader));
149149

@@ -242,7 +242,7 @@ public async Task AsyncUnaryCall_CompressedResponseWithUnknownEncoding_ErrorThro
242242
// Assert
243243
var ex = await ExceptionAssert.ThrowsAsync<RpcException>(() => call.ResponseAsync).DefaultTimeout();
244244
Assert.AreEqual(StatusCode.Unimplemented, ex.StatusCode);
245-
Assert.AreEqual("Unsupported grpc-encoding value 'not-supported'. Supported encodings: identity, gzip, deflate", ex.Status.Detail);
245+
Assert.AreEqual("Unsupported grpc-encoding value 'not-supported'. Supported encodings: identity, gzip", ex.Status.Detail);
246246
}
247247

248248
[Test]
@@ -322,7 +322,7 @@ await call.RequestStream.WriteAsync(new HelloRequest
322322
Assert.AreEqual("Hello world", response.Message);
323323

324324
Debug.Assert(httpRequestMessage != null);
325-
Assert.AreEqual("identity,gzip,deflate,test", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
325+
Assert.AreEqual("identity,gzip,test", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single());
326326
Assert.AreEqual("gzip", httpRequestMessage.Headers.GetValues(GrpcProtocolConstants.MessageEncodingHeader).Single());
327327
Assert.AreEqual(false, httpRequestMessage.Headers.Contains(GrpcProtocolConstants.CompressionRequestAlgorithmHeader));
328328

0 commit comments

Comments
 (0)