From fec79dcef321feb5a79fc73b62d45d80a71978e8 Mon Sep 17 00:00:00 2001 From: Deluvi Date: Fri, 26 Jun 2020 16:29:48 +0200 Subject: [PATCH] Modify Transfer-Encoding behavior to check for last encoding only --- src/unit.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/unit.rs b/src/unit.rs index 4616f28..6ca617b 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -38,7 +38,14 @@ impl Unit { let (is_transfer_encoding_set, mut is_chunked) = req .header("transfer-encoding") // if the user has set an encoding header, obey that. - .map(|enc| (!enc.is_empty(), enc == "chunked")) + .map(|enc| { + let is_transfer_encoding_set = !enc.is_empty(); + let last_encoding = enc.split(',').last(); + let is_chunked = last_encoding + .map(|last_enc| last_enc.trim() == "chunked") + .unwrap_or(false); + (is_transfer_encoding_set, is_chunked) + }) // otherwise, no chunking. .unwrap_or((false, false));