1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 08:22:59 +01:00

update tests

This commit is contained in:
Nikolay Kim 2018-03-08 18:19:46 -08:00
parent ebdc983dfe
commit f88f1c65b6
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; let mut len = 0;
while len < size { while len < size {
let mut chunk = self.items.pop_front().unwrap(); let mut chunk = self.items.pop_front().unwrap();
let rem = cmp::min(size - len, chunk.len()); let rem = cmp::min(size-len, chunk.len());
len -= rem; len += rem;
if rem < chunk.len() { if rem < chunk.len() {
chunk.split_to(rem); chunk.split_to(rem);
self.items.push_front(chunk); self.items.push_front(chunk);
@ -546,11 +546,11 @@ mod tests {
sender.feed_data(Bytes::from("line1")); sender.feed_data(Bytes::from("line1"));
sender.feed_data(Bytes::from("line2")); 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()); payload.readexactly(2).ok().unwrap());
assert_eq!(payload.len, 3); 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()); payload.readexactly(4).ok().unwrap());
assert_eq!(payload.len, 4); assert_eq!(payload.len, 4);

View File

@ -132,6 +132,11 @@ impl Frame {
pl.drop_payload(idx); pl.drop_payload(idx);
// get body // 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)? { let data = match pl.readexactly(length)? {
Async::Ready(Some(buf)) => buf, Async::Ready(Some(buf)) => buf,
Async::Ready(None) => return Ok(Async::Ready(None)), Async::Ready(None) => return Ok(Async::Ready(None)),