From de9b29ad1c93769c904ce04c9e8c90641a1f4230 Mon Sep 17 00:00:00 2001 From: sai0556 Date: Thu, 16 Sep 2021 00:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 示例20-9,20-7缺少Content-Length --- src/ch20-01-single-threaded.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch20-01-single-threaded.md b/src/ch20-01-single-threaded.md index 4167ff8..8aeb64c 100644 --- a/src/ch20-01-single-threaded.md +++ b/src/ch20-01-single-threaded.md @@ -315,7 +315,7 @@ fn handle_connection(mut stream: TcpStream) { let status_line = "HTTP/1.1 404 NOT FOUND\r\n\r\n"; let contents = fs::read_to_string("404.html").unwrap(); - let response = format!("{}{}", status_line, contents); + let response = format!("{}\r\nContent-Length: {}\r\n\r\n{}", status_line, contents); stream.write(response.as_bytes()).unwrap(); stream.flush().unwrap(); @@ -374,7 +374,7 @@ fn handle_connection(mut stream: TcpStream) { let contents = fs::read_to_string(filename).unwrap(); - let response = format!("{}{}", status_line, contents); + let response = format!("{}\r\nContent-Length: {}\r\n\r\n{}", status_line, contents); stream.write(response.as_bytes()).unwrap(); stream.flush().unwrap();