aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCeleste <colean@colean.cc>2021-12-26 18:27:56 +0000
committerCeleste <colean@colean.cc>2021-12-26 18:27:56 +0000
commit60af42f3fabc13cc986e795496ea2279ebee482c (patch)
tree083e4cb790351fd2eb4ffb8aa6c483e796085189
parent9f28bcdb84a9a95add8ac9203d4dfc8fa6d3f60c (diff)
Decorate index page.
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs13
3 files changed, 7 insertions, 10 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 82b6ff9..773f085 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,4 +4,4 @@ version = 3
[[package]]
name = "herb"
-version = "0.3.0"
+version = "0.3.1"
diff --git a/Cargo.toml b/Cargo.toml
index c3735d3..52a60cc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "herb"
-version = "0.3.0"
+version = "0.3.1"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/src/main.rs b/src/main.rs
index 5b02f1e..1cc04af 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,7 +25,7 @@ fn process_cgi(filename: String) -> String {
let output = Command::new(script)
.arg("GATEWAY_INTERFACE=\"CGI/1.1\"")
- .arg("SERVER_SOFTWARE=\"Herb/0.3.0\"")
+ .arg("SERVER_SOFTWARE=\"Herb/0.3.1\"")
.arg("REQUEST_METHOD=\"GET\"")
.arg(format!("QUERY_STRING=\"{}\"", query))
.arg(format!("SCRIPT_NAME=\"{}\"", script))
@@ -110,14 +110,12 @@ fn check_if_dir(directory: String) -> bool {
fn generate_index(directory: String) -> String {
- let mut index = format!("<!DOCTYPE HTML><html><body><h1>Directory of {}</h1>", directory);
+ let mut index = format!("<!DOCTYPE HTML><html><body><h1>Directory of {}</h1><hr/>", directory);
for file in fs::read_dir(directory).unwrap() {
-
- index = format!("{}<br/><a href={}>{:#?}</a>", index, file.as_ref().unwrap().path().display(), file.unwrap().file_name());
-
+ index = format!("{}<br/><a href={}>{:#?}</a>", index, format!("\"./{}\"", file.as_ref().unwrap().path().display().to_string()), file.unwrap().file_name());
}
- return index.to_string();
+ return format!("{}<hr/>Generated by herb 0.3.1", index).to_string();
}
@@ -244,7 +242,6 @@ fn serve(mut stream: TcpStream) {
.read_until(b'\n', &mut request)
.expect("Failed to read from stream!");
-
let resource = process_request(request);
// Haha, bodged my way around Rust's ownership paradigm!
@@ -258,7 +255,7 @@ fn serve(mut stream: TcpStream) {
let contents = get_page(resource);
let header = "HTTP/1.1 200 OK\r\n";
let content_type = format!("Content-Type: {}\r\n", mime);
- let server = "Server: Herb/0.3.0\r\n";
+ let server = "Server: Herb/0.3.1\r\n";
let extra_fields;
if cfg!(unix) {