diff --git a/CHANGES.md b/CHANGES.md index a42cbe6a0..7be1c98ee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ # Changes -## 0.6.1 (2018-05-xx) +## 0.6.1 (2018-05-08) + +* Fix http/2 payload streaming #215 * Fix connector's default `keep-alive` and `lifetime` settings #212 diff --git a/Cargo.toml b/Cargo.toml index fe63ef8a6..d88fc4aaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "0.6.0" +version = "0.6.1" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" diff --git a/src/pipeline.rs b/src/pipeline.rs index 25fe11e1d..e00c06178 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -492,8 +492,8 @@ impl ProcessResponse { if let Some(err) = self.resp.error() { if self.resp.status().is_server_error() { error!( - "Error occured during request handling: {}", - err + "Error occured during request handling, status: {} {}", + self.resp.status(), err ); } else { warn!( diff --git a/src/scope.rs b/src/scope.rs index c399ac76a..c5aefb699 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -787,10 +787,10 @@ mod tests { let mut app = App::new() .scope("app", |scope| { scope - .route("/path1", Method::GET, |r: HttpRequest<_>| { + .route("/path1", Method::GET, |_: HttpRequest<_>| { HttpResponse::Ok() }) - .route("/path1", Method::DELETE, |r: HttpRequest<_>| { + .route("/path1", Method::DELETE, |_: HttpRequest<_>| { HttpResponse::Ok() }) }) diff --git a/src/server/h2.rs b/src/server/h2.rs index e2013357a..fc7824b22 100644 --- a/src/server/h2.rs +++ b/src/server/h2.rs @@ -343,24 +343,27 @@ impl Entry { } fn poll_payload(&mut self) { - if !self.flags.contains(EntryFlags::REOF) { - if self.payload.need_read() == PayloadStatus::Read { - if let Err(err) = self.recv.release_capacity().release_capacity(32_768) { - self.payload.set_error(PayloadError::Http2(err)) - } - } else if let Err(err) = self.recv.release_capacity().release_capacity(0) { - self.payload.set_error(PayloadError::Http2(err)) - } - + while !self.flags.contains(EntryFlags::REOF) + && self.payload.need_read() == PayloadStatus::Read + { match self.recv.poll() { Ok(Async::Ready(Some(chunk))) => { + let l = chunk.len(); self.payload.feed_data(chunk); + if let Err(err) = self.recv.release_capacity().release_capacity(l) { + self.payload.set_error(PayloadError::Http2(err)); + break; + } } Ok(Async::Ready(None)) => { self.flags.insert(EntryFlags::REOF); + self.payload.feed_eof(); + } + Ok(Async::NotReady) => break, + Err(err) => { + self.payload.set_error(PayloadError::Http2(err)); + break; } - Ok(Async::NotReady) => (), - Err(err) => self.payload.set_error(PayloadError::Http2(err)), } } } diff --git a/tests/test_server.rs b/tests/test_server.rs index e61cedd3b..863f800ac 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -809,7 +809,7 @@ fn test_h2() { }) }); let _res = core.run(tcp); - // assert_eq!(res.unwrap(), Bytes::from_static(STR.as_ref())); + // assert_eq!(_res.unwrap(), Bytes::from_static(STR.as_ref())); } #[test]