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]]
name = "starfig"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"native-tls",
"packeteer",

View file

@ -1,6 +1,6 @@
[package]
name = "starfig"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
# 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" {
res.code = 51;
}
if res.code == 20 {
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);
stream.write(res_head.as_bytes()).unwrap();
stream.flush().unwrap();