Hello everyone,
today i started taking a look into tokio-rs/bytes
so i wrote a small program to start with,
#[tokio::main]
async fn main() -> io::Result<()> {
let mut buf = [0; 1024];
let req = b"GET /Chunked HTTP/1.1\r\n";
let mut tcp_stream = TcpStream::connect("anglesharp.azurewebsites.net:80").await?;
tcp_stream.write_all(req).await?;
timeout(Duration::from_secs(5), tcp_stream.read(&mut buf)).await??;
println!("{:?}", &buf[..]);
Ok(())
}
i know above that the request i am sending is not correct (as it should terminate with \r\n
) and when i do correct it to GET /Chunked HTTP/1.1\r\n\r\n
read works as expected.
when i send the incorrect request, i expect to receive a 400 http client error, and i would like to be able to read that error, i did inspect wireshark and indeed i saw the response, my question is why tokio hang on tcp_stream.read(&mut buf)
when provided when incorrect http request?