Refactor send_request for appservices

next
Jonas Platte 2021-04-23 18:38:20 +02:00 committed by Timo Kösters
parent 7067d7acae
commit e72fd44bb5
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
1 changed files with 37 additions and 42 deletions

View File

@ -49,11 +49,9 @@ where
*reqwest_request.timeout_mut() = Some(Duration::from_secs(30)); *reqwest_request.timeout_mut() = Some(Duration::from_secs(30));
let url = reqwest_request.url().clone(); let url = reqwest_request.url().clone();
let reqwest_response = globals.reqwest_client().execute(reqwest_request).await; let mut reqwest_response = globals.reqwest_client().execute(reqwest_request).await?;
// Because reqwest::Response -> http::Response is complicated: // Because reqwest::Response -> http::Response is complicated:
match reqwest_response {
Ok(mut reqwest_response) => {
let status = reqwest_response.status(); let status = reqwest_response.status();
let mut http_response = http::Response::builder().status(status); let mut http_response = http::Response::builder().status(status);
let headers = http_response.headers_mut().unwrap(); let headers = http_response.headers_mut().unwrap();
@ -93,7 +91,4 @@ where
); );
Error::BadServerResponse("Server returned bad response.") Error::BadServerResponse("Server returned bad response.")
}) })
}
Err(e) => Err(e.into()),
}
} }