mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 10:27:42 +02:00
ws tests and proper write payload ref
This commit is contained in:
@ -238,7 +238,7 @@ impl AsRef<[u8]> for Binary {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
match *self {
|
||||
Binary::Bytes(ref bytes) => &bytes[..],
|
||||
Binary::Bytes(ref bytes) => bytes.as_ref(),
|
||||
Binary::Slice(slice) => slice,
|
||||
Binary::SharedString(ref s) => s.as_bytes(),
|
||||
Binary::ArcSharedString(ref s) => s.as_bytes(),
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user