update meta handling

This commit is contained in:
abbie 2023-07-11 15:07:31 +01:00
parent c2f79d5a23
commit 65297831c8
Signed by: threeoh6000
GPG key ID: 801FE4AD456E922C
3 changed files with 9 additions and 3 deletions

2
Cargo.lock generated
View file

@ -218,7 +218,7 @@ dependencies = [
[[package]] [[package]]
name = "starfig" name = "starfig"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"native-tls", "native-tls",
"packeteer", "packeteer",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "starfig" name = "starfig"
version = "0.1.1" version = "0.1.2"
edition = "2021" edition = "2021"
# 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

@ -44,7 +44,13 @@ fn serve(mut stream: TlsStream<TcpStream>) {
if file == "# 51 Not Found\nThe resource you were looking for couldn't be found :(\nStarfig, gemini server by threeoh6000" { if file == "# 51 Not Found\nThe resource you were looking for couldn't be found :(\nStarfig, gemini server by threeoh6000" {
res.code = 51; res.code = 51;
} }
if res.code == 20 {
res.meta = "text/gemini".to_string(); res.meta = "text/gemini".to_string();
} else if res.code == 51 {
res.meta = "Not Found".to_string();
} else {
res.meta = "Err".to_string();
}
let (res_head, res_bod) = unpack_response(res); let (res_head, res_bod) = unpack_response(res);
stream.write(res_head.as_bytes()).unwrap(); stream.write(res_head.as_bytes()).unwrap();
stream.flush().unwrap(); stream.flush().unwrap();