From c4c89a22f8f1ebc74a13a6ee75a8209081dcb535 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 4 Jul 2017 12:52:41 -0700 Subject: [PATCH] fix(server): do not automatically set ContentLength for 204 and 304 Responses --- src/http/h1/parse.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/http/h1/parse.rs b/src/http/h1/parse.rs index 972acd352a..d0686eee23 100644 --- a/src/http/h1/parse.rs +++ b/src/http/h1/parse.rs @@ -131,9 +131,16 @@ impl Http1Transaction for ServerTransaction { body } - fn should_set_length(_head: &MessageHead) -> bool { + fn should_set_length(head: &MessageHead) -> bool { //TODO: pass method, check if method == HEAD - true + + match head.subject { + // TODO: support for 1xx codes needs improvement everywhere + // would be 100...199 => false + StatusCode::NoContent | + StatusCode::NotModified => false, + _ => true, + } } }