Bug with response using struct implementing bytes::Buf #3650
Labels
B-upstream
Blocked: needs a change in a dependency or the compiler.
C-bug
Category: bug. Something is wrong. This is bad!
Version
hyper: 1.3.1
hyper-util 0.1.3
bytes: 1.6.0
tokio: 1.37,0
Platform
Linux LAPTOP-CSN0P74T 5.15.146.1-microsoft-standard-WSL2
Summary
For a project I'm building I wanted to provide serialization of some internal structures and send them out as responses.
To do this I implemented a struct that implementes hyper::body::Body and implemented bytes::Buf for my internal structure.
When sending the structure I found that parts of the Buf had been replaced by different data.
Specifically I found that not all parts of the Buf were read and instead different data was inserted.
Minimal Viable Example
Here is a minimal example that implements the Buf interface over a Vec but only returns single byte slices.
What I would expect to happen is a response that contains the test message. What happens instead is that after every byte of that message it inserts the 7 bytes
\r\n0\r\n\r\n
and then advances past 7 bytes in the actual buffer without every asking for those chunks.I have checked it with a few different steps sizes, and it always seems to insert these specific 7 bytes if a chunk is returned that is not equal to the total size of remaining.
If the chunk length is equal to remaining then everything works.
Let me know if there is some additional information I could provide or something I could easily look into to help fix this.
The text was updated successfully, but these errors were encountered: