1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-30 10:32:55 +01:00

better method name

This commit is contained in:
Nikolay Kim 2017-11-19 18:55:37 -10:00
parent 766e243c63
commit 5945035fc3
3 changed files with 13 additions and 5 deletions

View File

@ -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<Binary> 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);

View File

@ -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]

View File

@ -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;