From: Martin Pitt <martin@piware.de>
Date: Fri, 16 Sep 2022 06:13:04 +0000 (+0200)
Subject: async-http: Fix unhandled warning
X-Git-Url: https://piware.de/gitweb/?a=commitdiff_plain;h=6a8be44a0b7527d9250309258d3055bbce125328;p=learn-rust.git

async-http: Fix unhandled warning
---

diff --git a/async-http/src/main.rs b/async-http/src/main.rs
index d9e3a26..95e7f07 100644
--- a/async-http/src/main.rs
+++ b/async-http/src/main.rs
@@ -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";