mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
better method name
This commit is contained in:
parent
766e243c63
commit
5945035fc3
12
src/body.rs
12
src/body.rs
@ -42,8 +42,8 @@ pub enum Binary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Body {
|
impl Body {
|
||||||
/// Does this body have payload.
|
/// Does this body streaming.
|
||||||
pub fn has_body(&self) -> bool {
|
pub fn is_streaming(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
Body::Length(_) | Body::Streaming => true,
|
Body::Length(_) | Body::Streaming => true,
|
||||||
_ => false
|
_ => false
|
||||||
@ -205,6 +205,14 @@ impl From<Binary> for Frame {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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]
|
#[test]
|
||||||
fn test_is_empty() {
|
fn test_is_empty() {
|
||||||
assert_eq!(Binary::from("").is_empty(), true);
|
assert_eq!(Binary::from("").is_empty(), true);
|
||||||
|
@ -439,8 +439,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_body() {
|
fn test_body() {
|
||||||
assert!(Body::Length(10).has_body());
|
assert!(Body::Length(10).is_streaming());
|
||||||
assert!(Body::Streaming.has_body());
|
assert!(Body::Streaming.is_streaming());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -303,7 +303,7 @@ impl Task {
|
|||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
let upgrade = msg.upgrade();
|
let upgrade = msg.upgrade();
|
||||||
if upgrade || msg.body().has_body() {
|
if upgrade || msg.body().is_streaming() {
|
||||||
self.iostate = TaskIOState::ReadingPayload;
|
self.iostate = TaskIOState::ReadingPayload;
|
||||||
} else {
|
} else {
|
||||||
self.iostate = TaskIOState::Done;
|
self.iostate = TaskIOState::Done;
|
||||||
|
Loading…
Reference in New Issue
Block a user