Dose the lines interator of BufReader of TcpStream never return None?

I'm learning Rust with the document on the official website.
I'm reading the part whose title is Build a Single-Thread Web Server.
The example code is

fn handle_connection(mut stream: TcpStream) {
    let buf_reader = BufReader::new(&mut stream);
    let http_request: Vec<_> = buf_reader
        .map(|result| result.unwrap())
        .take_while(|line| !line.is_empty())

    println!("Request: {:#?}", http_request);

But when I use the filter() instead of the take_while(), the thread will being blocked.

Isn't it like the title says, the lines iterator doesn't return None?

It will return None when the incoming stream is closed (which isn't representative of a web request).

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.