Merge pull request #561 from yin1999/patch-1

fix: response with correct HTTP/1.x Message format
pull/562/head
KaiserY 3 years ago committed by GitHub
commit 78c0fa1139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,7 +21,7 @@ use std::time::Duration;
// --snip--
fn handle_connection(mut stream: TcpStream) {
# let mut buffer = [0; 512];
# let mut buffer = [0; 1024];
# stream.read(&mut buffer).unwrap();
// --snip--
@ -29,12 +29,12 @@ fn handle_connection(mut stream: TcpStream) {
let sleep = b"GET /sleep HTTP/1.1\r\n";
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 if buffer.starts_with(sleep) {
thread::sleep(Duration::from_secs(5));
("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")
};
// --snip--

Loading…
Cancel
Save