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?;