wala-rust

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

commit 12f99c893237bbe9cda74820716c1bfd8ab590aa
parent eb25e875cf6747bc45f1331c74af15b3ebfd1741
Author: lash <dev@holbrook.no>
Date:   Tue, 27 Sep 2022 17:45:04 +0000

Force attachment when filename present

Diffstat:
Msrc/response.rs | 22+++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/response.rs b/src/response.rs @@ -122,7 +122,27 @@ pub fn exec_response(req: Request, r: RequestResult) { }; res.add_header(h); }, - _ => {}, + _ => { + let s = match content_type.as_str() { + "text/plain" => { + String::from("inline") + }, + "text/html" => { + String::from("inline") + }, + "text/markdown" => { + String::from("inline") + }, + _ => { + String::from("attachment") + }, + }; + let h = Header{ + field: HeaderField::from_str("Content-Disposition").unwrap(), + value: AsciiString::from_ascii(s.as_str()).unwrap(), + }; + res.add_header(h); + }, }; res = res.with_status_code(res_status);