// Block forever, handling each request that arrives at this IP address
for stream in listener.incoming() {
let stream = stream.unwrap();
-
handle_connection(stream);
}
}
fn handle_connection(mut stream: TcpStream) {
// Read the first 1024 bytes of data from the stream
let mut buffer = [0; 1024];
- stream.read(&mut buffer).unwrap();
+ assert!(stream.read(&mut buffer).unwrap() > 0);
let get = b"GET / HTTP/1.1\r\n";