From 7c0f57084559ce9c97fb09a49047e8c9059551f8 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 16 Jun 2019 21:54:17 +0600 Subject: [PATCH] Do not compress NoContent (204) responses #918 --- Cargo.toml | 4 ++-- actix-http/CHANGES.md | 7 +++++++ actix-http/Cargo.toml | 4 ++-- actix-http/src/encoding/encoder.rs | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8531a93ac..a18635684 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index d0c75da76..93c352898 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -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 diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 1847a5ba2..4411bdf6d 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -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" diff --git a/actix-http/src/encoding/encoder.rs b/actix-http/src/encoding/encoder.rs index aabce292a..d793eb4c7 100644 --- a/actix-http/src/encoding/encoder.rs +++ b/actix-http/src/encoding/encoder.rs @@ -33,6 +33,7 @@ impl Encoder { ) -> ResponseBody> { 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 MessageBody for Encoder { 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();