Compare commits

..

No commits in common. "user-agent" and "main" have entirely different histories.

3 changed files with 4 additions and 18 deletions

View file

@ -12,7 +12,7 @@ use crate::{
};
use bytes::Bytes;
use futures::StreamExt;
use http::{header::USER_AGENT, StatusCode};
use http::StatusCode;
use httpdate::fmt_http_date;
use itertools::Itertools;
use reqwest::{
@ -39,7 +39,6 @@ pub struct SendActivityTask {
pub(crate) inbox: Url,
pub(crate) private_key: RsaPrivateKey,
pub(crate) http_signature_compat: bool,
pub(crate) user_agent: String,
}
impl Display for SendActivityTask {
@ -84,7 +83,7 @@ impl SendActivityTask {
let request_builder = client
.post(self.inbox.to_string())
.timeout(timeout)
.headers(generate_request_headers(&self.inbox, &self.user_agent));
.headers(generate_request_headers(&self.inbox));
let request = sign_request(
request_builder,
&self.actor_id,
@ -174,7 +173,6 @@ where
activity: activity_serialized.clone(),
private_key: private_key.clone(),
http_signature_compat: config.http_signature_compat,
user_agent: config.user_agent().to_owned(),
})
})
.collect()
@ -213,7 +211,7 @@ where
.map_err(|e| Error::Other(format!("cloned error: {e}")))
}
pub(crate) fn generate_request_headers(inbox_url: &Url, user_agent: &str) -> HeaderMap {
pub(crate) fn generate_request_headers(inbox_url: &Url) -> HeaderMap {
let mut host = inbox_url.domain().expect("read inbox domain").to_string();
if let Some(port) = inbox_url.port() {
host = format!("{}:{}", host, port);
@ -224,11 +222,6 @@ pub(crate) fn generate_request_headers(inbox_url: &Url, user_agent: &str) -> Hea
HeaderName::from_static("content-type"),
HeaderValue::from_static(FEDERATION_CONTENT_TYPE),
);
headers.insert(
USER_AGENT,
HeaderValue::from_str(user_agent).expect("Hostname is valid"),
);
headers.insert(
HeaderName::from_static("host"),
HeaderValue::from_str(&host).expect("Hostname is valid"),
@ -237,7 +230,6 @@ pub(crate) fn generate_request_headers(inbox_url: &Url, user_agent: &str) -> Hea
"date",
HeaderValue::from_str(&fmt_http_date(SystemTime::now())).expect("Date is valid"),
);
println!("Generating request headers: {:?}", headers);
headers
}

View file

@ -191,11 +191,6 @@ impl<T: Clone> FederationConfig<T> {
pub fn domain(&self) -> &str {
&self.domain
}
/// Returns user-agent
pub fn user_agent(&self) -> &str {
&self.domain
}
}
impl<T: Clone> FederationConfigBuilder<T> {

View file

@ -11,7 +11,7 @@ use crate::{
FEDERATION_CONTENT_TYPE,
};
use bytes::Bytes;
use http::{header::USER_AGENT, HeaderValue, StatusCode};
use http::{HeaderValue, StatusCode};
use serde::de::DeserializeOwned;
use std::sync::atomic::Ordering;
use tracing::info;
@ -115,7 +115,6 @@ async fn fetch_object_http_with_accept<T: Clone, Kind: DeserializeOwned>(
.client
.get(url.as_str())
.header("Accept", content_type)
.header(USER_AGENT, data.config.user_agent())
.timeout(config.request_timeout);
let res = if let Some((actor_id, private_key_pem)) = config.signed_fetch_actor.as_deref() {