]> Untitled Git - lemmy.git/blobdiff - crates/apub_lib/src/signatures.rs
Consolidate and lower reqwest timeouts. Fixes #2150 (#2151)
[lemmy.git] / crates / apub_lib / src / signatures.rs
index 2ee3a144b424913955765384ba7de236a3d1ae44..6e5d6d25157f75ddd53b5f8dd1eb380c824bd28a 100644 (file)
@@ -4,7 +4,7 @@ use anyhow::anyhow;
 use http::{header::HeaderName, HeaderMap, HeaderValue};
 use http_signature_normalization_actix::Config as ConfigActix;
 use http_signature_normalization_reqwest::prelude::{Config, SignExt};
-use lemmy_utils::LemmyError;
+use lemmy_utils::{LemmyError, REQWEST_TIMEOUT};
 use once_cell::sync::Lazy;
 use openssl::{
   hash::MessageDigest,
@@ -15,7 +15,7 @@ use reqwest::Response;
 use reqwest_middleware::ClientWithMiddleware;
 use serde::{Deserialize, Serialize};
 use sha2::{Digest, Sha256};
-use std::{str::FromStr, time::Duration};
+use std::str::FromStr;
 use tracing::debug;
 use url::Url;
 
@@ -47,7 +47,7 @@ pub async fn sign_and_send(
   let request = client
     .post(&inbox_url.to_string())
     // signature is only valid for 10 seconds, so no reason to wait any longer
-    .timeout(Duration::from_secs(10))
+    .timeout(REQWEST_TIMEOUT)
     .headers(headers)
     .signature_with_digest(
       HTTP_SIG_CONFIG.clone(),