1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-20 14:10:45 +00:00

Do not compress NoContent (204) responses #918

This commit is contained in:
Nikolay Kim 2019-06-16 21:54:17 +06:00
parent eaa371db8b
commit 7c0f570845
4 changed files with 13 additions and 4 deletions

View file

@ -89,10 +89,10 @@ actix-cors = { version = "0.1.0", optional = true }
actix-identity = { version = "0.1.0", optional = true }
bytes = "0.4"
derive_more = "0.14"
derive_more = "0.15.0"
encoding = "0.2"
futures = "0.1.25"
hashbrown = "0.3.1"
hashbrown = "0.5.0"
log = "0.4"
mime = "0.3"
net2 = "0.2.33"

View file

@ -1,5 +1,12 @@
# Changes
## [0.2.4] - 2019-06-16
### Fixed
* Do not compress NoContent (204) responses #918
## [0.2.3] - 2019-06-02
### Added

View file

@ -56,11 +56,11 @@ bitflags = "1.0"
bytes = "0.4"
byteorder = "1.2"
copyless = "0.1.2"
derive_more = "0.14"
derive_more = "0.15.0"
either = "1.5.2"
encoding = "0.2"
futures = "0.1.25"
hashbrown = "0.3.0"
hashbrown = "0.5.0"
h2 = "0.1.16"
http = "0.1.17"
httparse = "1.3"

View file

@ -33,6 +33,7 @@ impl<B: MessageBody> Encoder<B> {
) -> ResponseBody<Encoder<B>> {
let can_encode = !(head.headers().contains_key(&CONTENT_ENCODING)
|| head.status == StatusCode::SWITCHING_PROTOCOLS
|| head.status == StatusCode::NO_CONTENT
|| encoding == ContentEncoding::Identity
|| encoding == ContentEncoding::Auto);
@ -122,6 +123,7 @@ impl<B: MessageBody> MessageBody for Encoder<B> {
Async::NotReady => return Ok(Async::NotReady),
Async::Ready(Some(chunk)) => {
if let Some(mut encoder) = self.encoder.take() {
self.encoded += chunk.len();
if chunk.len() < INPLACE {
encoder.write(&chunk)?;
let chunk = encoder.take();