From 67b78e2849191dc802a8c156afe67959c339d5c4 Mon Sep 17 00:00:00 2001 From: Quentin Perez Date: Fri, 22 Sep 2023 01:11:35 +0200 Subject: [PATCH] fix CI issue --- tests/compression/src/compressing_response.rs | 2 +- tonic/src/client/grpc.rs | 1 + tonic/src/codec/compression.rs | 6 ++++++ tonic/src/server/grpc.rs | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/compression/src/compressing_response.rs b/tests/compression/src/compressing_response.rs index 69f3bb6bc..7621f4a3f 100644 --- a/tests/compression/src/compressing_response.rs +++ b/tests/compression/src/compressing_response.rs @@ -167,7 +167,7 @@ async fn client_enabled_server_disabled_multi_encoding() { .into_inner(), ) .add_service(svc) - .serve_with_incoming(futures::stream::iter(vec![Ok::<_, std::io::Error>(server)])) + .serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)])) .await .unwrap(); } diff --git a/tonic/src/client/grpc.rs b/tonic/src/client/grpc.rs index 0d52fb42f..09ef3e934 100644 --- a/tonic/src/client/grpc.rs +++ b/tonic/src/client/grpc.rs @@ -399,6 +399,7 @@ impl GrpcConfig { .headers_mut() .insert(CONTENT_TYPE, HeaderValue::from_static("application/grpc")); + #[cfg(any(feature = "gzip", feature = "zstd"))] if let Some(encoding) = self.send_compression_encodings { request.headers_mut().insert( crate::codec::compression::ENCODING_HEADER, diff --git a/tonic/src/codec/compression.rs b/tonic/src/codec/compression.rs index bf94ca3fd..70d758415 100644 --- a/tonic/src/codec/compression.rs +++ b/tonic/src/codec/compression.rs @@ -153,6 +153,7 @@ impl CompressionEncoding { } #[allow(missing_docs)] + #[cfg(any(feature = "gzip", feature = "zstd"))] pub(crate) fn as_str(&self) -> &'static str { match self { #[cfg(feature = "gzip")] @@ -162,6 +163,7 @@ impl CompressionEncoding { } } + #[cfg(any(feature = "gzip", feature = "zstd"))] pub(crate) fn into_header_value(self) -> http::HeaderValue { http::HeaderValue::from_static(self.as_str()) } @@ -202,6 +204,8 @@ pub(crate) fn compress( ) -> Result<(), std::io::Error> { let capacity = ((len / BUFFER_SIZE) + 1) * BUFFER_SIZE; out_buf.reserve(capacity); + + #[cfg(any(feature = "gzip", feature = "zstd"))] let mut out_writer = bytes::BufMut::writer(out_buf); match encoding { @@ -241,6 +245,8 @@ pub(crate) fn decompress( let estimate_decompressed_len = len * 2; let capacity = ((estimate_decompressed_len / BUFFER_SIZE) + 1) * BUFFER_SIZE; out_buf.reserve(capacity); + + #[cfg(any(feature = "gzip", feature = "zstd"))] let mut out_writer = bytes::BufMut::writer(out_buf); match encoding { diff --git a/tonic/src/server/grpc.rs b/tonic/src/server/grpc.rs index d8ec2a89c..ec94b97fb 100644 --- a/tonic/src/server/grpc.rs +++ b/tonic/src/server/grpc.rs @@ -443,6 +443,7 @@ where http::header::HeaderValue::from_static("application/grpc"), ); + #[cfg(any(feature = "gzip", feature = "zstd"))] if let Some(encoding) = accept_encoding { // Set the content encoding parts.headers.insert(