Hi, I'm trying to do something like(?) a http parser and I need to get the body of the requests, I think the problem is the following line:
.take_while(|line| !line.is_empty())
here's the entire function:
pub fn get_req(mut stream: TcpStream) -> Vec<String> {
let buf = BufReader::new(&mut stream);
let raw_req: Vec<_> = buf
.lines()
.map(|result| result.unwrap())
.take_while(|line| !line.is_empty())
.collect();
return raw_req;
}
The request that I sent had body, you can see it in content-length, but for some reason the body isn't there
raw_req gives me that:
[
"GET / HTTP/1.1",
"content-length: 4",
"accept-encoding: gzip, deflate, br",
"Accept: /",
"User-Agent: Thunder Client (https://www.thunderclient.com)",
"Content-Type: text/plain",
"Host: localhost:7878",
"Connection: close",
]