fix: don't repeat (request-target)

This commit is contained in:
əlemi 2024-04-13 21:35:53 +02:00
parent 027040604c
commit 2e8d4323ee
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -132,9 +132,14 @@ impl HttpSignature {
pub fn build_manually(&mut self, method: &str, target: &str, mut headers: BTreeMap<String, String>) -> &mut Self { pub fn build_manually(&mut self, method: &str, target: &str, mut headers: BTreeMap<String, String>) -> &mut Self {
let mut out = Vec::new(); let mut out = Vec::new();
out.push(format!("(request-target): {method} {target}"));
for header in &self.headers { for header in &self.headers {
out.push(format!("{header}: {}", headers.remove(header).unwrap_or_default())); match header.as_str() {
"(request-target)" => out.push(format!("(request-target): {method} {target}")),
// TODO other pseudo-headers
_ => out.push(
format!("{header}: {}", headers.remove(header).unwrap_or_default())
),
}
} }
self.control = out.join("\n"); self.control = out.join("\n");
self self