hello people !! I'm just learning rust, and I was wondering how I can force EOF within BufReader without closing the TCP connection / what would be the best way of handling this situation? As it stands, when a user sends an http request to the server (snippet), the server doesn't start processing it until EOF (in this case, connection close). So the handle_request function gets fired off only when the connection is closed, resulting in its payload going to the void. I'm using std::io::BufReader
fn main() {
println!("Logs from your program will appear here!");
let listener = TcpListener::bind("127.0.0.1:4221").unwrap();
for stream in listener.incoming() {
match stream {
Ok(mut stream) => {
// let mut body = String::with_capacity(512);
let mut body = String::default();
println!("fuckckkkk");
let mut buf = BufReader::new(&mut stream);
println!("you digging in me king 😫");
buf.read_to_string(&mut body).unwrap();
let req = HttpRequest::from_string(&body);
println!("parsed connection");
handle_request(&mut stream, &req);
}
Err(e) => {
println!("error: {}", e);
}
}
}
}
