mirror of
https://github.com/alterware/alterware-launcher.git
synced 2025-12-04 15:27:48 +00:00
check for launcher update
This commit is contained in:
17
src/http.rs
17
src/http.rs
@@ -2,9 +2,20 @@ use std::{fs, io::Write, path::Path, str};
|
||||
|
||||
pub fn get_body(url: &str) -> Vec<u8> {
|
||||
let mut res: Vec<u8> = Vec::new();
|
||||
http_req::request::get(url, &mut res).unwrap_or_else(|error| {
|
||||
panic!("\n\n{}:\n{:?}", "Error", error);
|
||||
});
|
||||
let req = http_req::request::Request::new(&url.try_into().unwrap())
|
||||
.header(
|
||||
"User-Agent",
|
||||
"AlterWare Launcher | github.com/mxve/alterware-launcher",
|
||||
)
|
||||
.send(&mut res)
|
||||
.unwrap_or_else(|error| {
|
||||
panic!("\n\n{}:\n{:?}", "Error", error);
|
||||
});
|
||||
|
||||
if req.status_code() == http_req::response::StatusCode::new(302) {
|
||||
let location = req.headers().get("Location").unwrap().as_str();
|
||||
return get_body(location);
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user