From a51509f011cd7fc6e2732d92674df2b313b217be Mon Sep 17 00:00:00 2001 From: ducaale Date: Thu, 14 Apr 2022 23:35:50 +0100 Subject: [PATCH] remove warning in get_compression_type --- src/printer.rs | 9 ++------- tests/cli.rs | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/printer.rs b/src/printer.rs index 98c5d85b..4a8a8f53 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -1,5 +1,4 @@ use std::borrow::Cow; -use std::env; use std::io::{self, BufRead, BufReader, Read, Write}; use std::str::FromStr; @@ -577,6 +576,7 @@ impl FromStr for CompressionType { } } +// See https://github.com/seanmonstar/reqwest/blob/9bd4e90ec3401c2c5bc435c58954f3d52ab53e99/src/async_impl/decoder.rs#L150 fn get_compression_type(headers: &HeaderMap) -> Option { let mut compression_type = headers .get_all(CONTENT_ENCODING) @@ -590,14 +590,9 @@ fn get_compression_type(headers: &HeaderMap) -> Option { .find_map(|value| value.to_str().ok().and_then(|value| value.parse().ok())); } - if let Some(compression_type) = &compression_type { + if compression_type.is_some() { if let Some(content_length) = headers.get(CONTENT_LENGTH) { if content_length == "0" { - eprintln!( - "{}: warning: {:?} response with content-length of 0", - env!("CARGO_PKG_NAME"), - compression_type, - ); return None; } } diff --git a/tests/cli.rs b/tests/cli.rs index f7eee9eb..9fe50937 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -2846,7 +2846,6 @@ fn empty_response_with_content_encoding() { get_command() .arg(server.base_url()) .assert() - .stderr("xh: warning: Gzip response with content-length of 0\n") .stdout(indoc! {r#" HTTP/1.1 200 OK Content-Encoding: gzip