1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -04:00

Update ureq to 2.0

This commit is contained in:
Emil Ernerfeldt
2021-01-04 15:52:10 +01:00
parent 5a15e573ea
commit 1bcf35d774
3 changed files with 10 additions and 189 deletions

View File

@@ -6,12 +6,14 @@ pub fn fetch_blocking(request: &Request) -> Result<Response, String> {
let Request { method, url } = request;
let resp = ureq::request(method, url).set("Accept", "*/*").call();
if let Some(error) = resp.synthetic_error() {
return Err(error.to_string());
}
let (ok, resp) = match resp {
Ok(resp) => (true, resp),
Err(ureq::Error::Status(_, resp)) => (false, resp), // Still read the body on e.g. 404
Err(ureq::Error::Transport(error)) => return Err(error.to_string()),
};
let url = resp.get_url().to_owned();
let ok = resp.ok();
let status = resp.status();
let status_text = resp.status_text().to_owned();
let header_content_type = resp.header("Content-Type").unwrap_or_default().to_owned();