From 8a36e91fded90ac5c20de191497f542cfd1a917c Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 12 May 2024 02:26:55 +0200 Subject: [PATCH] fix: empty digest is rejected by mastodon, revert --- src/server/fetcher.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/server/fetcher.rs b/src/server/fetcher.rs index 271be3b9..b68f1590 100644 --- a/src/server/fetcher.rs +++ b/src/server/fetcher.rs @@ -33,10 +33,11 @@ pub trait Fetcher { let host = Context::server(url); let date = chrono::Utc::now().format("%a, %d %b %Y %H:%M:%S GMT").to_string(); // lmao @ "GMT" let path = url.replace("https://", "").replace("http://", "").replace(&host, ""); - let digest = match payload { - Some(x) => format!("sha-256={}", base64::prelude::BASE64_STANDARD.encode(openssl::sha::sha256(x.as_bytes()))), - None => "sha-256=".to_string(), - }; + let digest = format!("sha-256={}", + base64::prelude::BASE64_STANDARD.encode( + openssl::sha::sha256(payload.unwrap_or("").as_bytes()) + ) + ); let headers = vec!["(request-target)", "host", "date", "digest"]; let headers_map : BTreeMap = [