mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
63634be542
@ -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);
|
||||
|
||||
|
@ -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)),
|
||||
|
Loading…
Reference in New Issue
Block a user