Send dummy JSON when trying Misskey API endpoint

From Misskey 13, Misskey expects valid JSON (does not care its content
though) in POST body. To workaround this, send empty JSON object when
requesting Misskey API endpoint
This commit is contained in:
perillamint 2023-01-05 00:53:00 +09:00 committed by asonix
parent 4a7775b56d
commit 667d586160

View file

@ -305,7 +305,7 @@ impl Requests {
true => client.post(url), true => client.post(url),
false => client.get(url), false => client.get(url),
}; };
let res = client_req let client_signed = client_req
.insert_header(("Accept", accept)) .insert_header(("Accept", accept))
.insert_header(Date(SystemTime::now().into())) .insert_header(Date(SystemTime::now().into()))
.signature( .signature(
@ -316,9 +316,15 @@ impl Requests {
span.in_scope(|| signer.sign(signing_string)) span.in_scope(|| signer.sign(signing_string))
}, },
) )
.await? .await?;
.send() let res = match use_post {
.await; true => {
let dummy = serde_json::json!({});
client_signed.send_json(&dummy)
}
false => client_signed.send(),
}
.await;
let mut res = self.check_response(&parsed_url, res).await?; let mut res = self.check_response(&parsed_url, res).await?;