aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Hoeppner2014-11-28 16:18:25 +0100
committerTill Hoeppner2014-11-28 16:18:25 +0100
commit44188b8daa93fafcc73764087cc190fc0af384d7 (patch)
tree05ba68a1c2fb517907be3ee0e3d88ed31b080b5b
parented87bc33df3e14971e8bcb1472215d6caa9da170 (diff)
downloadsersve-44188b8daa93fafcc73764087cc190fc0af384d7.tar.gz
sersve-44188b8daa93fafcc73764087cc190fc0af384d7.tar.xz
sersve-44188b8daa93fafcc73764087cc190fc0af384d7.zip
Remove - now - unused content detection
-rw-r--r--Cargo.lock12
-rw-r--r--Cargo.toml2
-rw-r--r--src/sersve.rs20
3 files changed, 14 insertions, 20 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 30fde82..4575644 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,12 +2,19 @@
name = "sersve"
version = "0.0.1"
dependencies = [
+ "conduit-mime-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"iron 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"persistent 0.0.1 (git+https://github.com/iron/persistent)",
]
[[package]]
+name = "conduit-mime-types"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "cookie"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -63,6 +70,11 @@ dependencies = [
]
[[package]]
+name = "lazy_static"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "libressl-pnacl-sys"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 1a78c61..3c60d42 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,8 @@ path = "src/sersve.rs"
[dependencies]
iron = "*"
glob = "*"
+conduit-mime-types = "*"
+lazy_static = "~0.1.1"
[dependencies.persistent]
git = "https://github.com/iron/persistent"
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<B: Bodyable>(content: B) -> IronResult<Response> {
plain(content).map(|r| r.set(ContentType(Mime(Text, Html, Vec::new()))))
}
-fn binary<B: Bodyable>(content: B) -> IronResult<Response> {
- 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<Response> {
let (root, filter_str, max_size) = {
let o = req.get::<Read<OptCarrier, Mutex<Options>>>().unwrap();
@@ -187,7 +168,6 @@ fn serve(req: &mut Request) -> IronResult<Response> {
} else {
plain(content[])
}
- //if guess_text(content[]) { plain(content[]) } else { binary(content[]) }
} else {
let mut content = match fs::readdir(&path) {
Ok(s) => s,