2024-10-31 18:16:42 -04:00
|
|
|
use reqwest::Url;
|
2024-09-29 17:45:53 -04:00
|
|
|
|
2024-10-31 19:56:08 -04:00
|
|
|
pub async fn download(url: &Url) -> Result<Vec<u8>, reqwest::Error> {
|
2024-10-31 18:16:42 -04:00
|
|
|
let client = reqwest::Client::builder()
|
2024-10-31 21:46:50 -04:00
|
|
|
.no_proxy() // This fixes localhost connections... for some reason (https://github.com/seanmonstar/reqwest/issues/913)
|
2024-10-31 19:56:08 -04:00
|
|
|
.build()?;
|
2024-10-30 16:27:32 -04:00
|
|
|
|
2024-10-31 18:16:42 -04:00
|
|
|
let body = client.get(url.to_string())
|
|
|
|
.send()
|
|
|
|
.await;
|
2024-09-29 17:45:53 -04:00
|
|
|
|
2024-10-31 19:56:08 -04:00
|
|
|
Ok(body?.bytes().await?.to_vec())
|
2024-09-29 17:45:53 -04:00
|
|
|
}
|