diff --git a/src/body.rs b/src/body.rs index 7c1eaab33..0989611b1 100644 --- a/src/body.rs +++ b/src/body.rs @@ -42,8 +42,8 @@ pub enum Binary { } impl Body { - /// Does this body have payload. - pub fn has_body(&self) -> bool { + /// Does this body streaming. + pub fn is_streaming(&self) -> bool { match *self { Body::Length(_) | Body::Streaming => true, _ => false @@ -205,6 +205,14 @@ impl From for Frame { mod tests { use super::*; + #[test] + fn test_body_is_streaming() { + assert_eq!(Body::Empty.is_streaming(), false); + assert_eq!(Body::Binary(Binary::from("")).is_streaming(), false); + assert_eq!(Body::Length(100).is_streaming(), true); + assert_eq!(Body::Streaming.is_streaming(), true); + } + #[test] fn test_is_empty() { assert_eq!(Binary::from("").is_empty(), true); diff --git a/src/httpresponse.rs b/src/httpresponse.rs index 6e627b2af..00e80da16 100644 --- a/src/httpresponse.rs +++ b/src/httpresponse.rs @@ -439,8 +439,8 @@ mod tests { #[test] fn test_body() { - assert!(Body::Length(10).has_body()); - assert!(Body::Streaming.has_body()); + assert!(Body::Length(10).is_streaming()); + assert!(Body::Streaming.is_streaming()); } #[test] diff --git a/src/task.rs b/src/task.rs index 6530443b9..42387d580 100644 --- a/src/task.rs +++ b/src/task.rs @@ -303,7 +303,7 @@ impl Task { return Err(()) } let upgrade = msg.upgrade(); - if upgrade || msg.body().has_body() { + if upgrade || msg.body().is_streaming() { self.iostate = TaskIOState::ReadingPayload; } else { self.iostate = TaskIOState::Done;