1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-12-18 01:43:58 +01:00

fix 204 support for http/2

This commit is contained in:
Nikolay Kim 2018-10-09 13:12:49 -07:00
parent 4d17a9afcc
commit c63838bb71
2 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,12 @@
# Changes # Changes
## [0.7.11] - 2018-10-09
### Fixed
* Fixed 204 responses for http/2
## [0.7.10] - 2018-10-09 ## [0.7.10] - 2018-10-09
### Fixed ### Fixed

View File

@ -96,6 +96,7 @@ impl<H: 'static> Writer for H2Writer<H> {
let mut has_date = false; let mut has_date = false;
let mut resp = Response::new(()); let mut resp = Response::new(());
let mut len_is_set = false;
*resp.status_mut() = msg.status(); *resp.status_mut() = msg.status();
*resp.version_mut() = Version::HTTP_2; *resp.version_mut() = Version::HTTP_2;
for (key, value) in msg.headers().iter() { for (key, value) in msg.headers().iter() {
@ -107,6 +108,9 @@ impl<H: 'static> Writer for H2Writer<H> {
}, },
CONTENT_LENGTH => match info.length { CONTENT_LENGTH => match info.length {
ResponseLength::None => (), ResponseLength::None => (),
ResponseLength::Zero => {
len_is_set = true;
}
_ => continue, _ => continue,
}, },
DATE => has_date = true, DATE => has_date = true,
@ -126,8 +130,10 @@ impl<H: 'static> Writer for H2Writer<H> {
// content length // content length
match info.length { match info.length {
ResponseLength::Zero => { ResponseLength::Zero => {
resp.headers_mut() if !len_is_set {
.insert(CONTENT_LENGTH, HeaderValue::from_static("0")); resp.headers_mut()
.insert(CONTENT_LENGTH, HeaderValue::from_static("0"));
}
self.flags.insert(Flags::EOF); self.flags.insert(Flags::EOF);
} }
ResponseLength::Length(len) => { ResponseLength::Length(len) => {
@ -144,6 +150,9 @@ impl<H: 'static> Writer for H2Writer<H> {
resp.headers_mut() resp.headers_mut()
.insert(CONTENT_LENGTH, HeaderValue::try_from(l.as_str()).unwrap()); .insert(CONTENT_LENGTH, HeaderValue::try_from(l.as_str()).unwrap());
} }
ResponseLength::None => {
self.flags.insert(Flags::EOF);
}
_ => (), _ => (),
} }
if let Some(ce) = info.content_encoding { if let Some(ce) = info.content_encoding {