1
0
Fork 0
forked from alemi/upub

fix: send empty digest rather than digest of ""

maybe fixes iceshrimp? maybe breaks everyone else??
This commit is contained in:
əlemi 2024-05-11 19:19:42 +02:00
parent 1d19b8c2a6
commit e96b778392
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -33,8 +33,10 @@ pub trait Fetcher {
let host = Context::server(url); let host = Context::server(url);
let date = chrono::Utc::now().format("%a, %d %b %Y %H:%M:%S GMT").to_string(); // lmao @ "GMT" 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 path = url.replace("https://", "").replace("http://", "").replace(&host, "");
let payload_buf = payload.unwrap_or("").as_bytes(); let digest = match payload {
let digest = format!("sha-256={}", base64::prelude::BASE64_STANDARD.encode(openssl::sha::sha256(payload_buf))); Some(x) => format!("sha-256={}", base64::prelude::BASE64_STANDARD.encode(openssl::sha::sha256(x.as_bytes()))),
None => "sha-256=".to_string(),
};
let headers = vec!["(request-target)", "host", "date", "digest"]; let headers = vec!["(request-target)", "host", "date", "digest"];
let headers_map : BTreeMap<String, String> = [ let headers_map : BTreeMap<String, String> = [