From 44188b8daa93fafcc73764087cc190fc0af384d7 Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Fri, 28 Nov 2014 16:18:25 +0100 Subject: Remove - now - unused content detection --- src/sersve.rs | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src/sersve.rs') diff --git a/src/sersve.rs b/src/sersve.rs index 61c70dc..5d6c8ff 100644 --- a/src/sersve.rs +++ b/src/sersve.rs @@ -33,7 +33,6 @@ use iron::prelude::*; use iron::response::modifiers::*; use iron::status; use iron::mime::*; -use iron::mime::SubLevel::Ext as SubExt; use iron::middleware::ChainBuilder; use iron::typemap::Assoc; @@ -133,24 +132,6 @@ fn html(content: B) -> IronResult { plain(content).map(|r| r.set(ContentType(Mime(Text, Html, Vec::new())))) } -fn binary(content: B) -> IronResult { - plain(content).map( - |r| r.set(ContentType(Mime(Application, SubExt("octet-stream".into_string()), Vec::new())))) -} - -fn guess_text(data: &[u8]) -> bool { - let mut total = 0u; - let mut text = 0u; - for (c, _) in data.iter().zip(range(0u, 1000)) { - let c = *c as char; - if c.is_alphanumeric() || c.is_whitespace() { - text += 1; - } - total += 1; - } - text as f64 / total as f64 > 0.75 -} - fn serve(req: &mut Request) -> IronResult { let (root, filter_str, max_size) = { let o = req.get::>>().unwrap(); @@ -187,7 +168,6 @@ fn serve(req: &mut Request) -> IronResult { } else { plain(content[]) } - //if guess_text(content[]) { plain(content[]) } else { binary(content[]) } } else { let mut content = match fs::readdir(&path) { Ok(s) => s, -- cgit v1.2.3