mirror of
https://github.com/samsonjs/agate.git
synced 2026-03-29 09:45:48 +00:00
Code cleanup
This commit is contained in:
parent
c12b2ab656
commit
2cc5f791aa
1 changed files with 2 additions and 1 deletions
|
|
@ -130,11 +130,12 @@ async fn send_response<W: Write + Unpin>(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?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue