If you run my server code

do you get shutdown after 2 requests (on the third request) or after 1 (on the second) ?

When I run it, it shuts down on the second, and the code is set for 2 requests. My Rust repo

How did you make a requst? Note that browsers will automatically request /favicon.ico.

You might be able to gain more insights by logging requests. I’d start by trying this in the listener incoming loop:

println!("{}", stream);

I requested the main page and either /sleep or an undefined endpoint. the Rust book tutorial mentioned nothing about favicon.ico

The Rustbook tutorial mentioned nothing about logging requests or favicon.ico

favicon is a browser thing, not a rust thing; the book may not have expected the server to accept exactly two requests. If it runs until stopped, the browser asking for additional stuff won’t matter.