Closed julihoh closed 2 years ago
Thanks! On CI, cargo fmt
wants to make a change, but it's not clear to me why:
https://github.com/1tgr/rust-websocket-lite/runs/7482420549?check_suite_focus=true#step:5:15
Can you run cargo fmt
on your side?
Awesome! Thanks for fixing the formatting.
Are you planning to do a release soon?
It’s all done now, I published 0.5.2: https://crates.io/crates/websocket-codec/0.5.2
Thanks for the fix!
The current implementation of
MessageCodec
does not correctly handle the buffer when writing.Specifically, writing multiple websocket messages without flushing between each write will write incorrect frames.
The following does not work on the current implementation:
The reason for this misbehaviour is that the codec implementation assumes that it receives a new buffer for each write. However, according to the docs:
Ignoring this detail, the current implementation overwrites the existing buffer, leading to garbage frames being written.
This PR fixes this bug by correctly handling non-empty buffers in the Encoder implementation.