fix issue when getting long body in reqprops

This commit is contained in:
grimhilt 2023-07-13 16:02:20 +02:00
parent 0922066baa
commit b4cb78c676

View File

@ -126,19 +126,22 @@ impl ReqProps {
} }
pub fn send_with_err(&mut self) -> Result<String, ApiError> { pub fn send_with_err(&mut self) -> Result<String, ApiError> {
let res = tokio::runtime::Runtime::new().unwrap().block_on(async { tokio::runtime::Runtime::new().unwrap().block_on(async {
self.send().await match self.send().await {
}).map_err(ApiError::RequestError)?; Err(res) => Err(ApiError::RequestError(res)),
Ok(res) if res.status().is_success() => {
if res.status().is_success() { let body = res
let body = tokio::runtime::Runtime::new().unwrap().block_on(async { .text()
res.text().await .await
}).map_err(ApiError::EmptyError)?; .map_err(|err| ApiError::EmptyError(err))?;
Ok(body) Ok(body)
} else { },
Ok(res) => {
Err(ApiError::IncorrectRequest(res)) Err(ApiError::IncorrectRequest(res))
} }
} }
})
}
pub fn send_req_multiple(&mut self) -> Result<Vec<ObjProps>, ApiError> { pub fn send_req_multiple(&mut self) -> Result<Vec<ObjProps>, ApiError> {
match self.send_with_err() { match self.send_with_err() {