mirror of
https://github.com/actix/actix-web.git
synced 2024-12-19 06:36:36 +00:00
better method name
This commit is contained in:
parent
766e243c63
commit
5945035fc3
3 changed files with 13 additions and 5 deletions
12
src/body.rs
12
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<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);
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue