参考这篇文章进行练习
fn handle_client(stream: TcpStream) {
let mut buffer = [0; 512];
stream.read(&mut buffer).unwrap();
let contents = fs::read_to_string("main.html").unwrap();
let response = format!("HTTP/1.1 200 OK\r\n\r\n{}", contents);
stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
}
问题就在第一段代码
let mut buffer = [0; 512];
应改为
let mut buffer = [0; 1024];