wala-rust

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 35892e308b3a97195e0dd5e4eb5e2438e035513a
parent 0ef533d7bca38d36530933a7ed79174076209f3b
Author: lash <dev@holbrook.no>
Date:   Sun,  9 Oct 2022 08:22:12 +0000

Add capabilities headers

Diffstat:
MCHANGELOG | 3+++
MCargo.toml | 2+-
MROADMAP | 4++--
Msrc/response.rs | 42+++++++++++++++++++++++++++++++++---------
4 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,6 @@ +- 0.1.2 + * verify pgp signature from reader instead of copying to memory + * announce capabilities in headers - 0.1.1 * Replace pgp package with sequoia-openpgp - 0.1.0 diff --git a/Cargo.toml b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wala" -version = "0.1.1" +version = "0.1.2" edition = "2021" rust-version = "1.60" license = "GPL-3.0-or-later" diff --git a/ROADMAP b/ROADMAP @@ -1,2 +1,2 @@ -- 0.1.2 - * use reader instead of load to memory when verifying signatures +- 0.1.3 + * Remove all compile warnings diff --git a/src/response.rs b/src/response.rs @@ -34,6 +34,39 @@ pub fn origin_headers() -> Vec<Header> { field: HeaderField::from_str("Access-Control-Allow-Headers").unwrap(), value: AsciiString::from_ascii("Content-Type,Authorization,X-Filename").unwrap(), }); + + let server_header_v = format!("wala/{}, tiny_http (Rust)", env!("CARGO_PKG_VERSION")); + headers.push(Header{ + field: HeaderField::from_str("Server").unwrap(), + value: AsciiString::from_ascii(server_header_v).unwrap(), + }); + + let mut cap_headers: Vec<String> = vec!(); + #[cfg(feature="pgpauth")] + { + let h = String::from("auth_pgp"); + cap_headers.push(h); + }; + + #[cfg(feature="magic")] + { + let h = String::from("magic"); + cap_headers.push(h); + }; + + #[cfg(feature="meta")] + { + let h = String::from("meta"); + cap_headers.push(h); + }; + + if cap_headers.len() > 0 { + let v = cap_headers.join(","); + headers.push(Header{ + field: HeaderField::from_str("X-Wala-Cap").unwrap(), + value: AsciiString::from_ascii(v).unwrap(), + }); + } headers } @@ -77,12 +110,6 @@ pub fn exec_response(req: Request, r: RequestResult) { let auth_origin_headers = origin_headers(); - let server_header_v = format!("wala/{}, tiny_http (Rust)", env!("CARGO_PKG_VERSION")); - let server_header = Header{ - field: HeaderField::from_str("Server").unwrap(), - value: AsciiString::from_ascii(server_header_v).unwrap(), - }; - match r.v { Some(v) => { let mut res = Response::from_string(v); @@ -90,7 +117,6 @@ pub fn exec_response(req: Request, r: RequestResult) { for v in auth_origin_headers.iter() { res.add_header(v.clone()); } - res.add_header(server_header); req.respond(res); return; }, @@ -144,7 +170,6 @@ pub fn exec_response(req: Request, r: RequestResult) { for v in auth_origin_headers.iter() { res.add_header(v.clone()); } - res.add_header(server_header); req.respond(res); return; }, @@ -153,7 +178,6 @@ pub fn exec_response(req: Request, r: RequestResult) { for v in auth_origin_headers.iter() { res.add_header(v.clone()); } - res.add_header(server_header); req.respond(res); return; },