fix issue when getting long body in reqprops
This commit is contained in:
parent
0922066baa
commit
b4cb78c676
@ -126,18 +126,21 @@ 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 {
|
},
|
||||||
Err(ApiError::IncorrectRequest(res))
|
Ok(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> {
|
||||||
|
Loading…
Reference in New Issue
Block a user