From 791a980e2db66e4cc82285d7b9c3210447e83c01 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 2 Mar 2018 22:08:56 -0800 Subject: [PATCH] update tests --- Cargo.toml | 2 +- examples/basics/src/main.rs | 2 +- src/pipeline.rs | 3 ++- src/server/h1.rs | 9 +++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 44cd078f6..fef3bad0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,7 +81,7 @@ openssl = { version="0.10", optional = true } tokio-openssl = { version="0.2", optional = true } [dependencies.actix] -version = "0.5" +version = "^0.5.1" [dev-dependencies] env_logger = "0.5" diff --git a/examples/basics/src/main.rs b/examples/basics/src/main.rs index b93f5f20b..55e4485e0 100644 --- a/examples/basics/src/main.rs +++ b/examples/basics/src/main.rs @@ -139,7 +139,7 @@ fn main() { // default .default_resource(|r| { r.method(Method::GET).f(p404); - r.route().p(pred::Not(pred::Get())).f(|req| httpcodes::HTTPMethodNotAllowed); + r.route().filter(pred::Not(pred::Get())).f(|req| httpcodes::HTTPMethodNotAllowed); })) .bind("127.0.0.1:8080").expect("Can not bind to 127.0.0.1:8080") diff --git a/src/pipeline.rs b/src/pipeline.rs index 2fd21ec20..bd7801a36 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -173,7 +173,8 @@ impl> HttpHandlerTask for Pipeline { PipelineState::None => return Ok(Async::Ready(true)), PipelineState::Error => - return Err(io::Error::new(io::ErrorKind::Other, "Internal error").into()), + return Err(io::Error::new( + io::ErrorKind::Other, "Internal error").into()), _ => (), } diff --git a/src/server/h1.rs b/src/server/h1.rs index 8f0917dac..6d8f8df66 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -125,8 +125,8 @@ impl Http1 // TODO: refactor pub fn poll_io(&mut self) -> Poll { // read incoming data - let need_read = - if !self.flags.contains(Flags::ERROR) && self.tasks.len() < MAX_PIPELINED_MESSAGES + let need_read = if !self.flags.intersects(Flags::ERROR) && + self.tasks.len() < MAX_PIPELINED_MESSAGES { 'outer: loop { match self.reader.parse(self.stream.get_mut(), @@ -1413,6 +1413,10 @@ mod tests { assert!(req.chunked().unwrap()); assert!(!req.payload().eof()); + buf.feed_data("4\r\n1111\r\n"); + not_ready!(reader.parse(&mut buf, &mut readbuf, &settings)); + assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"1111"); + buf.feed_data("4\r\ndata\r"); not_ready!(reader.parse(&mut buf, &mut readbuf, &settings)); @@ -1430,6 +1434,7 @@ mod tests { buf.feed_data("ne\r\n0\r\n"); not_ready!(reader.parse(&mut buf, &mut readbuf, &settings)); + //trailers //buf.feed_data("test: test\r\n"); //not_ready!(reader.parse(&mut buf, &mut readbuf));