mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-30 18:44:35 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
63634be542
@ -342,7 +342,7 @@ impl<S> PayloadHelper<S> where S: Stream<Item=Bytes, Error=PayloadError> {
|
|||||||
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);
|
||||||
|
|
||||||
|
@ -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)),
|
||||||
|
Loading…
Reference in New Issue
Block a user