mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
simplify compression filter handling of server supported encoding headers
This commit is contained in:
parent
deff9d4df9
commit
c4d7fab13e
@ -240,10 +240,10 @@ export class CompressionFilter extends BaseFilter implements Filter {
|
||||
this.sharedFilterConfig.serverSupportedEncodingHeader = serverSupportedEncodingsHeader;
|
||||
const serverSupportedEncodings = serverSupportedEncodingsHeader.split(',');
|
||||
|
||||
if ((this.sendCompression instanceof DeflateHandler && !serverSupportedEncodings.includes('deflate'))
|
||||
|| (this.sendCompression instanceof GzipHandler && !serverSupportedEncodings.includes('gzip'))) {
|
||||
this.sendCompression = new IdentityHandler();
|
||||
}
|
||||
if (!serverSupportedEncodings.includes(this.currentCompressionAlgorithm)) {
|
||||
this.sendCompression = new IdentityHandler();
|
||||
this.currentCompressionAlgorithm = 'identity';
|
||||
}
|
||||
}
|
||||
metadata.remove('grpc-accept-encoding');
|
||||
return metadata;
|
||||
|
||||
@ -33,6 +33,7 @@ import { loadProtoFile } from './common';
|
||||
import { TestServiceClient, TestServiceHandlers } from './generated/TestService';
|
||||
import { ProtoGrpcType as TestServiceGrpcType } from './generated/test_service';
|
||||
import { Request__Output } from './generated/Request';
|
||||
import { CompressionAlgorithms } from '../src/compression-algorithms';
|
||||
|
||||
const loadedTestServiceProto = protoLoader.loadSync('test/fixtures/test_service.proto', {
|
||||
keepCase: true,
|
||||
@ -683,7 +684,7 @@ describe('Compressed requests', () => {
|
||||
`localhost:${assignedPort}`,
|
||||
grpc.credentials.createInsecure(),
|
||||
{
|
||||
'grpc.default_compression_algorithm': 1
|
||||
'grpc.default_compression_algorithm': CompressionAlgorithms.deflate
|
||||
}
|
||||
);
|
||||
done();
|
||||
@ -774,7 +775,7 @@ describe('Compressed requests', () => {
|
||||
`localhost:${assignedPort}`,
|
||||
grpc.credentials.createInsecure(),
|
||||
{
|
||||
'grpc.default_compression_algorithm': 2
|
||||
'grpc.default_compression_algorithm': CompressionAlgorithms.gzip
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user