From 438011dd72c50a309d6ca0de78b3ac6bb2189f57 Mon Sep 17 00:00:00 2001 From: Paul Hooijenga Date: Wed, 22 Nov 2023 15:44:13 +0100 Subject: [PATCH] Do not encode zero-sized response bodies --- actix-http/CHANGES.md | 4 ++++ actix-http/src/encoding/encoder.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 318df5a4d..fc49bc931 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -6,6 +6,10 @@ - Updated `zstd` dependency to `0.13`. +### Fixed + +- Do not encode zero-sized response bodies + ## 3.4.0 ### Added diff --git a/actix-http/src/encoding/encoder.rs b/actix-http/src/encoding/encoder.rs index 527bfebaa..e084aa564 100644 --- a/actix-http/src/encoding/encoder.rs +++ b/actix-http/src/encoding/encoder.rs @@ -52,7 +52,7 @@ impl Encoder { pub fn response(encoding: ContentEncoding, head: &mut ResponseHead, body: B) -> Self { // no need to compress an empty body - if matches!(body.size(), BodySize::None) { + if matches!(body.size(), BodySize::None | BodySize::Sized(0)) { return Self::none(); }