Fix CGI implementation
This commit is contained in:
parent
5e783bcbb6
commit
2823990ec8
3 changed files with 11 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4,4 +4,4 @@ version = 3
|
|||
|
||||
[[package]]
|
||||
name = "herb"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "herb"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -21,14 +21,15 @@ fn process_cgi(filename: String) -> String {
|
|||
query = "";
|
||||
script = &filename;
|
||||
}
|
||||
println!("{}", script);
|
||||
|
||||
|
||||
let output = Command::new(script)
|
||||
.arg("GATEWAY_INTERFACE=\"CGI/1.1\"")
|
||||
.arg("SERVER_SOFTWARE=\"Herb/0.3.1\"")
|
||||
.arg("REQUEST_METHOD=\"GET\"")
|
||||
.arg(format!("QUERY_STRING=\"{}\"", query))
|
||||
.arg(format!("SCRIPT_NAME=\"{}\"", script))
|
||||
let output = Command::new(format!("./{}", script))
|
||||
.env("GATEWAY_INTERFACE", "CGI/1.1")
|
||||
.env("SERVER_SOFTWARE", "Herb/0.4.0")
|
||||
.env("REQUEST_METHOD", "GET")
|
||||
.env("QUERY_STRING", query)
|
||||
.env("SCRIPT_NAME", script)
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
let outputd = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
|
@ -115,7 +116,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());
|
||||
}
|
||||
|
||||
return format!("{}<hr/>Generated by herb 0.3.1", index).to_string();
|
||||
return format!("{}<hr/>Generated by herb 0.4.0", index).to_string();
|
||||
|
||||
}
|
||||
|
||||
|
@ -255,7 +256,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.1\r\n";
|
||||
let server = "Server: Herb/0.4.0\r\n";
|
||||
let extra_fields;
|
||||
|
||||
if cfg!(unix) {
|
||||
|
|
Loading…
Reference in a new issue