0.6.1: fixes #6
This commit is contained in:
parent
c8857e70e6
commit
229526cbe1
4 changed files with 7 additions and 11 deletions
|
@ -1 +1 @@
|
||||||
4
|
5
|
||||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4,7 +4,7 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "herb"
|
name = "herb"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"packeteer",
|
"packeteer",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "herb"
|
name = "herb"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -35,7 +35,6 @@ fn process_cgi(filename: String) -> String {
|
||||||
query = "";
|
query = "";
|
||||||
script = &filename;
|
script = &filename;
|
||||||
}
|
}
|
||||||
println!("{}", script);
|
|
||||||
|
|
||||||
let output;
|
let output;
|
||||||
if query != "" {
|
if query != "" {
|
||||||
|
@ -72,11 +71,8 @@ fn detect_media_type(filename: String) -> String {
|
||||||
if paths == true && dir == false && filename.contains(".") == false {
|
if paths == true && dir == false && filename.contains(".") == false {
|
||||||
return "text/html".to_string();
|
return "text/html".to_string();
|
||||||
} else {
|
} else {
|
||||||
let ext_index = filename.to_string().find(".").unwrap();
|
let ext_index = filename.as_str().split(".").collect::<Vec<&str>>();
|
||||||
let test = ext_index + 1;
|
let ext = ext_index[ext_index.len()-1];
|
||||||
let ext = &filename[test..];
|
|
||||||
|
|
||||||
if filename[test..].contains("cgi") { return "text/html".to_string(); }
|
|
||||||
|
|
||||||
match ext {
|
match ext {
|
||||||
"aac" => "audio/aac".to_string(),
|
"aac" => "audio/aac".to_string(),
|
||||||
|
@ -140,7 +136,7 @@ fn generate_index(directory: String) -> String {
|
||||||
index = format!("{}<a href={}>{}</a><br/>", index, format!("\"/{}\"", file.as_ref().unwrap().path().display().to_string()), file.unwrap().file_name().into_string().unwrap_or("!!".to_string()));
|
index = format!("{}<a href={}>{}</a><br/>", index, format!("\"/{}\"", file.as_ref().unwrap().path().display().to_string()), file.unwrap().file_name().into_string().unwrap_or("!!".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return format!("{}<hr/>Generated by herb {}", index, env!("CARGO_PKG_VERSION")).to_string();
|
return format!("{}<hr/><i>Generated by herb/{}</i>", index, env!("CARGO_PKG_VERSION")).to_string();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +240,7 @@ fn process_request(request: Vec<u8>) -> Resource {
|
||||||
|
|
||||||
// Did you want to see chars.as_str().to_string()?
|
// Did you want to see chars.as_str().to_string()?
|
||||||
let rescontents = get_page(output.to_string());
|
let rescontents = get_page(output.to_string());
|
||||||
let mut resource = Resource { contents: rescontents.contents, status_code: 200, mime: detect_media_type(output.to_string()) };
|
let mut resource = Resource { contents: rescontents.contents, status_code: 200, mime: detect_media_type(output.split("?").collect::<Vec<&str>>()[0].to_string()) };
|
||||||
if rescontents.is500 {
|
if rescontents.is500 {
|
||||||
resource.status_code = 500;
|
resource.status_code = 500;
|
||||||
resource.mime = "text/html".to_string();
|
resource.mime = "text/html".to_string();
|
||||||
|
|
Loading…
Reference in a new issue