move reqwest client out of thread spawning

this way, we only spawn one, and reuse that.
This commit is contained in:
Igor Galić 2020-02-17 23:37:43 +01:00
parent 65b2c38c29
commit be8c67ee9a
No known key found for this signature in database
GPG Key ID: ACFEFF7F6A123A86

View File

@ -152,11 +152,11 @@ where
headers.insert("Digest", request::Digest::digest(&body)); headers.insert("Digest", request::Digest::digest(&body));
let sig = request::signature(sender, &headers) let sig = request::signature(sender, &headers)
.expect("activity_pub::broadcast: request signature error"); .expect("activity_pub::broadcast: request signature error");
rt.spawn(async move {
let client = ClientBuilder::new() let client = ClientBuilder::new()
.connect_timeout(std::time::Duration::from_secs(5)) .connect_timeout(std::time::Duration::from_secs(5))
.build() .build()
.expect("Can't build client"); .expect("Can't build client");
rt.spawn(async move {
client client
.post(&inbox) .post(&inbox)
.headers(headers.clone()) .headers(headers.clone())