mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-14 04:41:49 +08:00
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.
This commit is contained in:
parent
70a197b5d8
commit
515246b920
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user