From 06e5042b94c93aaa8c18b8702eaf6611c895b42f Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 24 Oct 2020 22:15:01 +0200 Subject: [PATCH] use idenity encoding on client if no compression features are enabled (#1737) Co-authored-by: Yuki Okushi Co-authored-by: Rob Ede --- awc/CHANGES.md | 7 +++++++ awc/Cargo.toml | 1 + awc/src/request.rs | 13 +++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 8babba113..0b02b3cfa 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,8 +1,15 @@ # Changes ## Unreleased - 2020-xx-xx +### Changed * Upgrade `base64` to `0.13`. +### Fixed +* Use `Accept-Encoding: identity` instead of `Accept-Encoding: br` when no compression feature is enabled [#1737] + +[#1737]: https://github.com/actix/actix-web/pull/1737 + + ## 2.0.0 - 2020-09-11 ### Changed * `Client::build` was renamed to `Client::builder`. diff --git a/awc/Cargo.toml b/awc/Cargo.toml index b8cf53e06..b7d8b0a22 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -44,6 +44,7 @@ actix-rt = "1.0.0" base64 = "0.13" bytes = "0.5.3" +cfg-if = "1.0" derive_more = "0.99.2" futures-core = { version = "0.3.5", default-features = false } log =" 0.4" diff --git a/awc/src/request.rs b/awc/src/request.rs index dcada2c6d..11e1da6a3 100644 --- a/awc/src/request.rs +++ b/awc/src/request.rs @@ -21,10 +21,15 @@ use crate::frozen::FrozenClientRequest; use crate::sender::{PrepForSendingError, RequestSender, SendClientRequest}; use crate::ClientConfig; -#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))] -const HTTPS_ENCODING: &str = "br, gzip, deflate"; -#[cfg(not(any(feature = "flate2-zlib", feature = "flate2-rust")))] -const HTTPS_ENCODING: &str = "br"; +cfg_if::cfg_if! { + if #[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))] { + const HTTPS_ENCODING: &str = "br, gzip, deflate"; + } else if #[cfg(feature = "compress")] { + const HTTPS_ENCODING: &str = "br"; + } else { + const HTTPS_ENCODING: &str = "identity"; + } +} /// An HTTP Client request builder ///