You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnnil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err)
849
-
}
850
-
ifsize>maxReceiveMessageSize {
851
-
out.Free()
852
-
// TODO: Revisit the error code. Currently keep it consistent with java
853
-
// implementation.
854
-
returnnil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max (%d vs. %d)", size, maxReceiveMessageSize)
837
+
returnnil, err
855
838
}
856
839
} else {
857
840
out=compressed
@@ -866,20 +849,46 @@ func recvAndDecompress(p *parser, s recvCompressor, dc Decompressor, maxReceiveM
866
849
returnout, nil
867
850
}
868
851
869
-
// Using compressor, decompress d, returning data and size.
870
-
// Optionally, if data will be over maxReceiveMessageSize, just return the size.
871
-
funcdecompress(compressor encoding.Compressor, d mem.BufferSlice, maxReceiveMessageSizeint, pool mem.BufferPool) (mem.BufferSlice, int, error) {
872
-
dcReader, err:=compressor.Decompress(d.Reader())
873
-
iferr!=nil {
874
-
returnnil, 0, err
852
+
// decompress processes the given data by decompressing it using either a custom decompressor or a standard compressor.
853
+
// If a custom decompressor is provided, it takes precedence. The function validates that the decompressed data
854
+
// does not exceed the specified maximum size and returns an error if this limit is exceeded.
855
+
// On success, it returns the decompressed data. Otherwise, it returns an error if decompression fails or the data exceeds the size limit.
856
+
funcdecompress(compressor encoding.Compressor, d mem.BufferSlice, dcDecompressor, maxReceiveMessageSizeint, pool mem.BufferPool) (mem.BufferSlice, error) {
857
+
ifdc!=nil {
858
+
uncompressed, err:=dc.Do(d.Reader())
859
+
iferr!=nil {
860
+
returnnil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err)
861
+
}
862
+
iflen(uncompressed) >maxReceiveMessageSize {
863
+
returnnil, status.Errorf(codes.ResourceExhausted, "grpc: message after decompression larger than max (%d vs. %d)", len(uncompressed), maxReceiveMessageSize)
0 commit comments