mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 23:51:06 +01:00
fix 204 support for http/2
This commit is contained in:
parent
4d17a9afcc
commit
c63838bb71
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user