diff --git a/CHANGES.md b/CHANGES.md index 46f1fb36..260b6df7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [0.7.11] - 2018-10-09 + +### Fixed + +* Fixed 204 responses for http/2 + + ## [0.7.10] - 2018-10-09 ### Fixed diff --git a/src/server/h2writer.rs b/src/server/h2writer.rs index 51d4dce6..66f2923c 100644 --- a/src/server/h2writer.rs +++ b/src/server/h2writer.rs @@ -96,6 +96,7 @@ impl Writer for H2Writer { let mut has_date = false; let mut resp = Response::new(()); + let mut len_is_set = false; *resp.status_mut() = msg.status(); *resp.version_mut() = Version::HTTP_2; for (key, value) in msg.headers().iter() { @@ -107,6 +108,9 @@ impl Writer for H2Writer { }, CONTENT_LENGTH => match info.length { ResponseLength::None => (), + ResponseLength::Zero => { + len_is_set = true; + } _ => continue, }, DATE => has_date = true, @@ -126,8 +130,10 @@ impl Writer for H2Writer { // content length match info.length { ResponseLength::Zero => { - resp.headers_mut() - .insert(CONTENT_LENGTH, HeaderValue::from_static("0")); + if !len_is_set { + resp.headers_mut() + .insert(CONTENT_LENGTH, HeaderValue::from_static("0")); + } self.flags.insert(Flags::EOF); } ResponseLength::Length(len) => { @@ -144,6 +150,9 @@ impl Writer for H2Writer { resp.headers_mut() .insert(CONTENT_LENGTH, HeaderValue::try_from(l.as_str()).unwrap()); } + ResponseLength::None => { + self.flags.insert(Flags::EOF); + } _ => (), } if let Some(ce) = info.content_encoding {