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 5fc2b62
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
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 5fc2b62

Please sign in to comment.