From 2cc5f791aa760503ce6e1edb6cc5204d7f9d3668 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 16 Jul 2020 08:50:36 -0700 Subject: [PATCH] Code cleanup --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 34ba9bd..86f28d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,11 +130,12 @@ async fn send_response(url: &Url, mut stream: W) -> Result { } } + // Make sure the file opens successfully before sending the success header. let mut file = async_std::fs::File::open(&path).await?; // Send header. if path.extension() == Some(OsStr::new("gmi")) { - stream.write_all(b"20 text/gemini\r\n").await?; + respond(&mut stream, "20", &["text/gemini"]).await?; } else { let mime = tree_magic_mini::from_filepath(&path).ok_or("Can't read file")?; respond(&mut stream, "20", &[mime]).await?;