diff --git a/src/handshake/client.rs b/src/handshake/client.rs index 615b413..a8a7d8a 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -52,7 +52,7 @@ impl<'t> Request<'t> { /// Adds a custom header to the request. pub fn add_header(&mut self, name: Cow<'t, str>, value: Cow<'t, str>) { - let mut headers = self.extra_headers.take().unwrap_or_else(|| vec![]); + let mut headers = self.extra_headers.take().unwrap_or_else(Vec::new); headers.push((name, value)); self.extra_headers = Some(headers); } diff --git a/src/protocol/frame/frame.rs b/src/protocol/frame/frame.rs index 3016704..c5bf9c2 100644 --- a/src/protocol/frame/frame.rs +++ b/src/protocol/frame/frame.rs @@ -107,7 +107,7 @@ impl FrameHeader { | if self.mask.is_some() { 0x80 } else { 0 } }; - output.write(&[one, two])?; + output.write_all(&[one, two])?; match lenfmt { LengthFormat::U8(_) => (), LengthFormat::U16 => output.write_u16::(length as u16)?, diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index d1eb958..8b3de04 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -109,6 +109,13 @@ impl WebSocket { self.socket.get_mut() } + /// Change the configuration. + pub fn set_config(&mut self, set_func: impl FnOnce(&mut WebSocketConfig)) { + set_func(&mut self.config) + } +} + +impl WebSocket { /// Convert a frame socket into a WebSocket. fn from_frame_socket( socket: FrameSocket,