1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-28 01:52:57 +01:00

Merge branch 'master' into master

This commit is contained in:
kingxsp 2018-03-09 10:22:15 +08:00 committed by GitHub
commit 63634be542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -341,8 +341,8 @@ impl<S> PayloadHelper<S> where S: Stream<Item=Bytes, Error=PayloadError> {
let mut len = 0;
while len < size {
let mut chunk = self.items.pop_front().unwrap();
let rem = cmp::min(size - len, chunk.len());
len -= rem;
let rem = cmp::min(size-len, chunk.len());
len += rem;
if rem < chunk.len() {
chunk.split_to(rem);
self.items.push_front(chunk);
@ -546,11 +546,11 @@ mod tests {
sender.feed_data(Bytes::from("line1"));
sender.feed_data(Bytes::from("line2"));
assert_eq!(Async::Ready(Some(BytesMut::from("li"))),
assert_eq!(Async::Ready(Some(Bytes::from_static(b"li"))),
payload.readexactly(2).ok().unwrap());
assert_eq!(payload.len, 3);
assert_eq!(Async::Ready(Some(BytesMut::from("ne1l"))),
assert_eq!(Async::Ready(Some(Bytes::from_static(b"ne1l"))),
payload.readexactly(4).ok().unwrap());
assert_eq!(payload.len, 4);

View File

@ -132,6 +132,11 @@ impl Frame {
pl.drop_payload(idx);
// get body
if length == 0 {
return Ok(Async::Ready(Some(Frame {
finished, rsv1, rsv2, rsv3, opcode, payload: Binary::from("") })));
}
let data = match pl.readexactly(length)? {
Async::Ready(Some(buf)) => buf,
Async::Ready(None) => return Ok(Async::Ready(None)),