I’m trying to implement the PROXY protocol for an HTTP server I’m writing. Since PROXY is a variable width header for each connection, I need some way of not reading past its delimiter and clobbering the beginning of the first request.
My first idea was to just wrap the
tokio_core::net::TcpStream in a
BufRead implementation, but Hyper already buffers internally and I’d like to avoid double buffering.
I would like to be able to use
tokio_core::net::TcpStream does not have
peek(), nor is there any way I could find to extract the
Does anyone have any ideas of how to go about this? Unfortunately there doesn’t seem to be much example code for this kind of stuff that I could find.
Thank you in advance.
P. S. Another option I thought about was just reading two bytes at a time, but that seems horrifically wasteful.