Reinstate 30 second pict-rs timeout

asonix/remove-awc
Aode (lion) 2021-12-06 18:22:30 -06:00
parent 338f0a63a1
commit 737161ceca
1 changed files with 10 additions and 5 deletions

View File

@ -10,6 +10,7 @@ use lemmy_websocket::LemmyContext;
use reqwest::Body;
use reqwest_middleware::{ClientWithMiddleware, RequestBuilder};
use serde::{Deserialize, Serialize};
use std::time::Duration;
pub fn config(cfg: &mut web::ServiceConfig, client: ClientWithMiddleware, rate_limit: &RateLimit) {
cfg
@ -50,16 +51,20 @@ fn adapt_request(
// remove accept-encoding header so that pictrs doesnt compress the response
const INVALID_HEADERS: &[HeaderName] = &[ACCEPT_ENCODING, HOST];
request.headers().iter().fold(
client.request(request.method().clone(), url),
|client_req, (key, value)| {
let client_request = client
.request(request.method().clone(), url)
.timeout(Duration::from_secs(30));
request
.headers()
.iter()
.fold(client_request, |client_req, (key, value)| {
if INVALID_HEADERS.contains(key) {
client_req
} else {
client_req.header(key, value)
}
},
)
})
}
async fn upload(