Skip to content

Commit

Permalink
Fix extra byte in websocket binary frame on EIO v3
Browse files Browse the repository at this point in the history
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 Totodore#277.
  • Loading branch information
kelnos committed Mar 1, 2024
1 parent c8bbd22 commit 38b900d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion engineioxide/src/transport/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down

0 comments on commit 38b900d

Please sign in to comment.