switch 403 forbidden to 500 Internal Server Error

This commit is contained in:
abbie 2022-08-28 10:54:00 +01:00
parent 2823990ec8
commit 66dfbd2291
No known key found for this signature in database
GPG key ID: A575D2415E5E5B6D
3 changed files with 6 additions and 6 deletions

2
Cargo.lock generated
View file

@ -4,4 +4,4 @@ version = 3
[[package]] [[package]]
name = "herb" name = "herb"
version = "0.4.0" version = "0.4.1"

View file

@ -1,6 +1,6 @@
[package] [package]
name = "herb" name = "herb"
version = "0.4.0" version = "0.4.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

View file

@ -26,7 +26,7 @@ fn process_cgi(filename: String) -> String {
let output = Command::new(format!("./{}", script)) let output = Command::new(format!("./{}", script))
.env("GATEWAY_INTERFACE", "CGI/1.1") .env("GATEWAY_INTERFACE", "CGI/1.1")
.env("SERVER_SOFTWARE", "Herb/0.4.0") .env("SERVER_SOFTWARE", "Herb/0.4.1")
.env("REQUEST_METHOD", "GET") .env("REQUEST_METHOD", "GET")
.env("QUERY_STRING", query) .env("QUERY_STRING", query)
.env("SCRIPT_NAME", script) .env("SCRIPT_NAME", script)
@ -116,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()); 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.0", index).to_string(); return format!("{}<hr/>Generated by herb 0.4.1", index).to_string();
} }
@ -156,7 +156,7 @@ fn get_page(filename: String) -> String {
let result = fs::read_to_string(filename); let result = fs::read_to_string(filename);
match result { match result {
Ok(i) => i.to_string(), Ok(i) => i.to_string(),
Err(_e) => "<!DOCTYPE HTML><html><body><h1>403 Forbidden</h1><p>The resource you are trying to access cannot be read by the server.</p></body></html>".to_string(), Err(_e) => "<!DOCTYPE HTML><html><body><h1>500 Internal Server Error</h1><p>The resource you are trying to access cannot be read by the server.</p></body></html>".to_string(),
} }
} }
@ -256,7 +256,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.0\r\n"; let server = "Server: Herb/0.4.1\r\n";
let extra_fields; let extra_fields;
if cfg!(unix) { if cfg!(unix) {