]> piware.de Git - learn-rust.git/blobdiff - async-http/src/main.rs
async-http: Fix unhandled warning
[learn-rust.git] / async-http / src / main.rs
index d9e3a26bfaf8c22af808f51a61e1f50b09534a17..95e7f07687562f23df7591299f18a0066290fd2f 100644 (file)
@@ -12,7 +12,6 @@ fn main() {
     // Block forever, handling each request that arrives at this IP address
     for stream in listener.incoming() {
         let stream = stream.unwrap();
-
         handle_connection(stream);
     }
 }
@@ -20,7 +19,7 @@ fn main() {
 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";