From 38b900dcb02aaa51dd47f365592f9508d8ee9cbb Mon Sep 17 00:00:00 2001 From: "Brian J. Tarricone" Date: Fri, 1 Mar 2024 00:29:17 -0800 Subject: [PATCH] Fix extra byte in websocket binary frame on EIO v3 In v3 of the engine.io protocol, the packet type byte is prepended to the binary data that is sent out on a websocket binary frame. This byte needs to be stripped off the data before it's sent to the handler. Closes #277. --- engineioxide/src/transport/ws.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engineioxide/src/transport/ws.rs b/engineioxide/src/transport/ws.rs index 490174dd..dc037d01 100644 --- a/engineioxide/src/transport/ws.rs +++ b/engineioxide/src/transport/ws.rs @@ -182,7 +182,11 @@ where } p => return Err(Error::BadPacket(p)), }, - Message::Binary(data) => { + Message::Binary(mut data) => { + if socket.protocol == ProtocolVersion::V3 && !data.is_empty() { + // The first byte is the message type, which we don't need. + let _ = data.remove(0); + } engine.handler.on_binary(data, socket.clone()); Ok(()) }