fix issue when getting long body in reqprops
This commit is contained in:
parent
0922066baa
commit
b4cb78c676
@ -126,19 +126,22 @@ impl ReqProps {
|
||||
}
|
||||
|
||||
pub fn send_with_err(&mut self) -> Result<String, ApiError> {
|
||||
let res = tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
self.send().await
|
||||
}).map_err(ApiError::RequestError)?;
|
||||
|
||||
if res.status().is_success() {
|
||||
let body = tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
res.text().await
|
||||
}).map_err(ApiError::EmptyError)?;
|
||||
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
match self.send().await {
|
||||
Err(res) => Err(ApiError::RequestError(res)),
|
||||
Ok(res) if res.status().is_success() => {
|
||||
let body = res
|
||||
.text()
|
||||
.await
|
||||
.map_err(|err| ApiError::EmptyError(err))?;
|
||||
Ok(body)
|
||||
} else {
|
||||
},
|
||||
Ok(res) => {
|
||||
Err(ApiError::IncorrectRequest(res))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_req_multiple(&mut self) -> Result<Vec<ObjProps>, ApiError> {
|
||||
match self.send_with_err() {
|
||||
|
Loading…
Reference in New Issue
Block a user