Skip to content

Commit

Permalink
fix CI issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Perez committed Sep 21, 2023
1 parent 0510e60 commit 67b78e2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/compression/src/compressing_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions tonic/src/client/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tonic/src/codec/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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())
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions tonic/src/server/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 67b78e2

Please sign in to comment.