mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 20:45:29 +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?;
|
let mut file = async_std::fs::File::open(&path).await?;
|
||||||
|
|
||||||
// Send header.
|
// Send header.
|
||||||
if path.extension() == Some(OsStr::new("gmi")) {
|
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 {
|
} else {
|
||||||
let mime = tree_magic_mini::from_filepath(&path).ok_or("Can't read file")?;
|
let mime = tree_magic_mini::from_filepath(&path).ok_or("Can't read file")?;
|
||||||
respond(&mut stream, "20", &[mime]).await?;
|
respond(&mut stream, "20", &[mime]).await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue