1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-22 17:41:11 +00: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
## [0.7.11] - 2018-10-09
### Fixed
* Fixed 204 responses for http/2
## [0.7.10] - 2018-10-09
### Fixed

View file

@ -96,6 +96,7 @@ impl<H: 'static> Writer for H2Writer<H> {
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<H: 'static> Writer for H2Writer<H> {
},
CONTENT_LENGTH => match info.length {
ResponseLength::None => (),
ResponseLength::Zero => {
len_is_set = true;
}
_ => continue,
},
DATE => has_date = true,
@ -126,8 +130,10 @@ impl<H: 'static> Writer for H2Writer<H> {
// 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<H: 'static> Writer for H2Writer<H> {
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 {