diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs
index 1d28a0a39..3882c2d52 100644
--- a/actix-http/src/h1/dispatcher.rs
+++ b/actix-http/src/h1/dispatcher.rs
@@ -309,11 +309,8 @@ where
}
}
- // SAFETY: setting length to 0 is safe
- // skips one length check vs truncate
- unsafe {
- write_buf.set_len(0);
- }
+ // everything has written to io. clear buffer.
+ write_buf.clear();
// flush the io and check if get blocked.
let blocked = io.poll_flush(cx)?.is_pending();
diff --git a/actix-http/src/ws/frame.rs b/actix-http/src/ws/frame.rs
index 8c49524e6..78d487dd2 100644
--- a/actix-http/src/ws/frame.rs
+++ b/actix-http/src/ws/frame.rs
@@ -16,7 +16,8 @@ impl Parser {
src: &[u8],
server: bool,
max_size: usize,
- ) -> Result