mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-02-22 20:22:18 +08:00
修复示例代码中的语法错误
This commit is contained in:
parent
9e8eda274d
commit
9b39aa307b
@ -315,7 +315,11 @@ fn handle_connection(mut stream: TcpStream) {
|
|||||||
let status_line = "HTTP/1.1 404 NOT FOUND\r\n\r\n";
|
let status_line = "HTTP/1.1 404 NOT FOUND\r\n\r\n";
|
||||||
let contents = fs::read_to_string("404.html").unwrap();
|
let contents = fs::read_to_string("404.html").unwrap();
|
||||||
|
|
||||||
let response = format!("{}\r\nContent-Length: {}\r\n\r\n{}", status_line, contents);
|
let response = format!("{}\r\nContent-Length: {}\r\n\r\n{}",
|
||||||
|
status_line,
|
||||||
|
contents.len(),
|
||||||
|
contents
|
||||||
|
);
|
||||||
|
|
||||||
stream.write(response.as_bytes()).unwrap();
|
stream.write(response.as_bytes()).unwrap();
|
||||||
stream.flush().unwrap();
|
stream.flush().unwrap();
|
||||||
@ -374,7 +378,11 @@ fn handle_connection(mut stream: TcpStream) {
|
|||||||
|
|
||||||
let contents = fs::read_to_string(filename).unwrap();
|
let contents = fs::read_to_string(filename).unwrap();
|
||||||
|
|
||||||
let response = format!("{}\r\nContent-Length: {}\r\n\r\n{}", status_line, contents);
|
let response = format!("{}\r\nContent-Length: {}\r\n\r\n{}",
|
||||||
|
status_line,
|
||||||
|
contents.len(),
|
||||||
|
contents
|
||||||
|
);
|
||||||
|
|
||||||
stream.write(response.as_bytes()).unwrap();
|
stream.write(response.as_bytes()).unwrap();
|
||||||
stream.flush().unwrap();
|
stream.flush().unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user