Get request body from BufReader<&mut TcpStream>>

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
        .map(|result| result.unwrap())
        .take_while(|line| !line.is_empty())
    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 (",
"Content-Type: text/plain",
"Host: localhost:7878",
"Connection: close",

I think lines only returns data once it sees a line break, but I don't believe the body of an HTTP request is generally expected to terminate with a line break.

@hyousef solved this here

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.