0.4.2: If there is no query string for CGI then the QUERY_STRING env var isn't set.
This commit is contained in:
parent
66dfbd2291
commit
ba06ad686a
3 changed files with 23 additions and 13 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4,4 +4,4 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "herb"
|
name = "herb"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "herb"
|
name = "herb"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
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
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -23,15 +23,25 @@ fn process_cgi(filename: String) -> String {
|
||||||
}
|
}
|
||||||
println!("{}", script);
|
println!("{}", script);
|
||||||
|
|
||||||
|
let output;
|
||||||
let output = Command::new(format!("./{}", script))
|
if query != "" {
|
||||||
|
output = Command::new(format!("./{}", script))
|
||||||
.env("GATEWAY_INTERFACE", "CGI/1.1")
|
.env("GATEWAY_INTERFACE", "CGI/1.1")
|
||||||
.env("SERVER_SOFTWARE", "Herb/0.4.1")
|
.env("SERVER_SOFTWARE", "Herb/0.4.2")
|
||||||
.env("REQUEST_METHOD", "GET")
|
.env("REQUEST_METHOD", "GET")
|
||||||
.env("QUERY_STRING", query)
|
.env("QUERY_STRING", query)
|
||||||
.env("SCRIPT_NAME", script)
|
.env("SCRIPT_NAME", script)
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
} else {
|
||||||
|
output = Command::new(format!("./{}", script))
|
||||||
|
.env("GATEWAY_INTERFACE", "CGI/1.1")
|
||||||
|
.env("SERVER_SOFTWARE", "Herb/0.4.2")
|
||||||
|
.env("REQUEST_METHOD", "GET")
|
||||||
|
.env("SCRIPT_NAME", script)
|
||||||
|
.output()
|
||||||
|
.expect("failed to execute process");
|
||||||
|
}
|
||||||
let outputd = String::from_utf8_lossy(&output.stdout).to_string();
|
let outputd = String::from_utf8_lossy(&output.stdout).to_string();
|
||||||
return outputd;
|
return outputd;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +126,7 @@ fn generate_index(directory: String) -> String {
|
||||||
index = format!("{}<br/><a href={}>{:#?}</a>", index, format!("\"./{}\"", file.as_ref().unwrap().path().display().to_string()), 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 format!("{}<hr/>Generated by herb 0.4.1", index).to_string();
|
return format!("{}<hr/>Generated by herb 0.4.2", index).to_string();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +266,7 @@ fn serve(mut stream: TcpStream) {
|
||||||
let contents = get_page(resource);
|
let contents = get_page(resource);
|
||||||
let header = "HTTP/1.1 200 OK\r\n";
|
let header = "HTTP/1.1 200 OK\r\n";
|
||||||
let content_type = format!("Content-Type: {}\r\n", mime);
|
let content_type = format!("Content-Type: {}\r\n", mime);
|
||||||
let server = "Server: Herb/0.4.1\r\n";
|
let server = "Server: Herb/0.4.2\r\n";
|
||||||
let extra_fields;
|
let extra_fields;
|
||||||
|
|
||||||
if cfg!(unix) {
|
if cfg!(unix) {
|
||||||
|
|
Loading…
Reference in a new issue