0.7.1: Update packeteer version to add error handling for malformed requests.

This commit is contained in:
abbie 2024-01-15 15:13:02 +00:00
parent ce9600a56f
commit c93706815e
Signed by: threeoh6000
GPG key ID: 801FE4AD456E922C
3 changed files with 13 additions and 8 deletions

6
Cargo.lock generated
View file

@ -4,13 +4,13 @@ version = 3
[[package]] [[package]]
name = "herb" name = "herb"
version = "0.7.0" version = "0.7.1"
dependencies = [ dependencies = [
"packeteer", "packeteer",
] ]
[[package]] [[package]]
name = "packeteer" name = "packeteer"
version = "0.5.1" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "582fc2c3395c690f0d079658b1acc23848b294f5a0753c54675011f09a0ec815" checksum = "5425d35ba9635d531e8d6e0a4bd9b0974decbb146e7f7f69fffb071e44bcb647"

View file

@ -1,9 +1,7 @@
[package] [package]
name = "herb" name = "herb"
version = "0.7.0" version = "0.7.1"
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
packeteer = { version = "0.5.1", features = ["http1"] } packeteer = { version = "0.5.2", features = ["http1"] }

View file

@ -225,7 +225,14 @@ fn grab_time() -> String{
fn process_request(request: Vec<u8>) -> Resource { fn process_request(request: Vec<u8>) -> Resource {
let input = String::from_utf8_lossy(&request).to_string(); let input = String::from_utf8_lossy(&request).to_string();
let request = construct_request(&input); let prerequest = construct_request(&input);
let request;
if prerequest.is_some() {
request = prerequest.unwrap();
} else {
let resource = Resource { contents: "<!DOCTYPE HTML><html><body><h1>400 Bad Request</h1><p>The request you sent appears to be malformed.</p></body></html>".to_string().into_bytes(), status_code: 400, mime: "text/html".to_string(), iscgi: false };
return resource;
}
let mut path: String; let mut path: String;
let mut index = String::new(); let mut index = String::new();