1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

fix awc compress feature (#2116)

This commit is contained in:
fakeshadow 2021-03-25 15:47:37 -07:00 committed by GitHub
parent 3188ef5731
commit 8c2ce2dedb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 15 deletions

View File

@ -55,7 +55,6 @@ base64 = "0.13"
bitflags = "1.2" bitflags = "1.2"
bytes = "1" bytes = "1"
bytestring = "1" bytestring = "1"
cfg-if = "1"
cookie = { version = "0.14.1", features = ["percent-encode"], optional = true } cookie = { version = "0.14.1", features = ["percent-encode"], optional = true }
derive_more = "0.99.5" derive_more = "0.99.5"
encoding_rs = "0.8" encoding_rs = "0.8"

View File

@ -2,9 +2,11 @@
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
### Changed ### Changed
* `ConnectorService` type is renamed to `BoxConnectorService` [#2081] * `ConnectorService` type is renamed to `BoxConnectorService`. [#2081]
* Fix http/https encoding when enabling `compress` feature. [#2116]
[#2081]: https://github.com/actix/actix-web/pull/2081 [#2081]: https://github.com/actix/actix-web/pull/2081
[#2116]: https://github.com/actix/actix-web/pull/2116
## 3.0.0-beta.3 - 2021-03-08 ## 3.0.0-beta.3 - 2021-03-08

View File

@ -51,7 +51,6 @@ actix-rt = { version = "2.1", default-features = false }
base64 = "0.13" base64 = "0.13"
bytes = "1" bytes = "1"
cfg-if = "1.0"
derive_more = "0.99.5" derive_more = "0.99.5"
futures-core = { version = "0.3.7", default-features = false } futures-core = { version = "0.3.7", default-features = false }
itoa = "0.4" itoa = "0.4"

View File

@ -21,15 +21,10 @@ use crate::frozen::FrozenClientRequest;
use crate::sender::{PrepForSendingError, RequestSender, SendClientRequest}; use crate::sender::{PrepForSendingError, RequestSender, SendClientRequest};
use crate::ClientConfig; use crate::ClientConfig;
cfg_if::cfg_if! { #[cfg(feature = "compress")]
if #[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))] { const HTTPS_ENCODING: &str = "br, gzip, deflate";
const HTTPS_ENCODING: &str = "br, gzip, deflate"; #[cfg(not(feature = "compress"))]
} else if #[cfg(feature = "compress")] { const HTTPS_ENCODING: &str = "br";
const HTTPS_ENCODING: &str = "br";
} else {
const HTTPS_ENCODING: &str = "identity";
}
}
/// An HTTP Client request builder /// An HTTP Client request builder
/// ///
@ -521,11 +516,11 @@ impl ClientRequest {
.unwrap_or(true); .unwrap_or(true);
if https { if https {
slf = slf.insert_header_if_none((header::ACCEPT_ENCODING, HTTPS_ENCODING)) slf = slf.insert_header_if_none((header::ACCEPT_ENCODING, HTTPS_ENCODING));
} else { } else {
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))] #[cfg(feature = "compress")]
{ {
slf = slf.insert_header_if_none((header::ACCEPT_ENCODING, "gzip, deflate")) slf = slf.insert_header_if_none((header::ACCEPT_ENCODING, "gzip, deflate"));
} }
}; };
} }