1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 18:37:41 +02:00

ws tests and proper write payload ref

This commit is contained in:
Nikolay Kim
2018-03-19 09:30:58 -07:00
parent f4a47ef71e
commit e7ec0f9fd7
3 changed files with 45 additions and 4 deletions

View File

@ -227,9 +227,10 @@ impl<T: AsyncWrite, H: 'static> Writer for H1Writer<T, H> {
// shortcut for upgraded connection
if self.flags.contains(Flags::UPGRADE) {
if self.buffer.is_empty() {
let n = self.write_data(payload.as_ref())?;
if payload.len() < n {
self.buffer.extend_from_slice(&payload.as_ref()[n..]);
let pl: &[u8] = payload.as_ref();
let n = self.write_data(pl)?;
if pl.len() < n {
self.buffer.extend_from_slice(&pl[n..]);
return Ok(WriterState::Done);
}
} else {