mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 07:36:43 +00:00
allocate enough space
This commit is contained in:
parent
ce8294740e
commit
e4b3f79458
1 changed files with 4 additions and 3 deletions
|
@ -172,13 +172,14 @@ impl Parser {
|
|||
};
|
||||
|
||||
if payload_len < 126 {
|
||||
dst.reserve(p_len + 2 + if mask { 4 } else { 0 });
|
||||
dst.put_slice(&[one, two | payload_len as u8]);
|
||||
} else if payload_len <= 65_535 {
|
||||
dst.reserve(p_len + 4);
|
||||
dst.reserve(p_len + 4 + if mask { 4 } else { 0 });
|
||||
dst.put_slice(&[one, two | 126]);
|
||||
dst.put_u16_be(payload_len as u16);
|
||||
} else {
|
||||
dst.reserve(p_len + 10);
|
||||
dst.reserve(p_len + 10 + if mask { 4 } else { 0 });
|
||||
dst.put_slice(&[one, two | 127]);
|
||||
dst.put_u64_be(payload_len as u64);
|
||||
};
|
||||
|
@ -186,7 +187,7 @@ impl Parser {
|
|||
if mask {
|
||||
let mask = rand::random::<u32>();
|
||||
dst.put_u32_le(mask);
|
||||
dst.extend_from_slice(payload.as_ref());
|
||||
dst.put_slice(payload.as_ref());
|
||||
let pos = dst.len() - payload_len;
|
||||
apply_mask(&mut dst[pos..], mask);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue