wala-rust

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

commit 09b32cd80a7a16289acae5196f423b611baf3d0d
parent acbee1f54efe3fdbb52c2b9e8d7c22a7ae34c678
Author: lash <dev@holbrook.no>
Date:   Wed, 22 Feb 2023 14:02:57 +0000

200 return on empty get, always returns caps header

Diffstat:
MCHANGELOG | 5+++++
MCargo.toml | 2+-
Msrc/request.rs | 5+++++
Msrc/response.rs | 14++++++++------
4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,8 @@ +- 0.1.5 + * Return 200 on empty get + * Set "X-Wala-Cap" header to "default" when no extra capabilities are present +- 0.1.4 + * Remove stray println - 0.1.3 * Fall back to application/octet-stream if mime type is missing - 0.1.2 diff --git a/Cargo.toml b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wala" -version = "0.1.4" +version = "0.1.5" edition = "2021" rust-version = "1.60" license = "GPL-3.0-or-later" diff --git a/src/request.rs b/src/request.rs @@ -87,6 +87,11 @@ pub fn process_method(method: &Method, url: String, mut f: impl Read, expected_s } }, Method::Get => { + if &url == "" { + let mut res = RequestResult::new(RequestResultType::Found); + res = res.with_content(String::new()); + return res; + } let digest = match hex::decode(&url) { Err(e) => { let err_str = format!("{}", e); diff --git a/src/response.rs b/src/response.rs @@ -60,13 +60,15 @@ pub fn origin_headers() -> Vec<Header> { 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(), - }); + if cap_headers.len() == 0 { + cap_headers.push(String::from("default")); } + + let v = cap_headers.join(","); + headers.push(Header{ + field: HeaderField::from_str("X-Wala-Cap").unwrap(), + value: AsciiString::from_ascii(v).unwrap(), + }); headers }