From 515246b9209b0bc8adeb08feb0aee065272a115a Mon Sep 17 00:00:00 2001 From: A1lo Date: Tue, 9 Nov 2021 10:38:45 +0800 Subject: [PATCH] fix: response with correct HTTP/1.x Message format The correct `HTTP/1.x Message`'s headers are followed after the `start-line` which describing the requests to be implemented. After the `headers` is a `blank line` indicating all `meta-information` for the request has been sent. Then the `optional body` is followed. --- 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 b88f22a..4418b79 100644 --- a/src/ch20-01-single-threaded.md +++ b/src/ch20-01-single-threaded.md @@ -371,9 +371,9 @@ fn handle_connection(mut stream: TcpStream) { // --snip-- let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK\r\n\r\n", "hello.html") + ("HTTP/1.1 200 OK", "hello.html") } else { - ("HTTP/1.1 404 NOT FOUND\r\n\r\n", "404.html") + ("HTTP/1.1 404 NOT FOUND", "404.html") }; let contents = fs::read_to_string(filename).unwrap();