1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-30 16:40:21 +02:00

refactor Payload stream

This commit is contained in:
Nikolay Kim
2017-10-26 23:14:33 -07:00
parent 488fb256b4
commit fb0270e27d
9 changed files with 56 additions and 48 deletions

View File

@@ -512,18 +512,18 @@ impl InnerField {
Ok(Async::Ready(None))
} else {
match payload.readany() {
Async::NotReady => Ok(Async::NotReady),
Async::Ready(None) => Ok(Async::Ready(None)),
Async::Ready(Some(Ok(mut chunk))) => {
let len = cmp::min(chunk.len() as u64, *size);
Ok(Async::NotReady) => Ok(Async::NotReady),
Ok(Async::Ready(None)) => Ok(Async::Ready(None)),
Ok(Async::Ready(Some(mut chunk))) => {
let len = cmp::min(chunk.0.len() as u64, *size);
*size -= len;
let ch = chunk.split_to(len as usize);
if !chunk.is_empty() {
payload.unread_data(chunk);
let ch = chunk.0.split_to(len as usize);
if !chunk.0.is_empty() {
payload.unread_data(chunk.0);
}
Ok(Async::Ready(Some(ch)))
},
Async::Ready(Some(Err(err))) => Err(err.into())
Err(err) => Err(err.into())
}
}
}