From 97884a183f378fd996029cde769df2e974fff1eb Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 27 Mar 2022 06:03:33 +0000 Subject: feat(response): respond with file --- src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 0d201da..4ffabba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -314,13 +314,19 @@ impl Router { .write_all( format!( "{}{}\r\n{}", - response_status, + if response_status == 21 { + 20 + } else { + response_status + }, match response_status { - 20 => " text/gemini; charset=utf-8", - _ => &*content, + 20 => " text/gemini; charset=utf-8".to_string(), + 21 => tree_magic::from_u8(&*content.as_bytes()), + _ => (&*content).to_string(), }, match response_status { 20 => format!("{}{}{}", header, content, footer), + 21 => (&*content).to_string(), _ => "".to_string(), } ) -- cgit v1.2.3