Skip to content

Commit

Permalink
resourceloader: Automatically set proxy for http request if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Aug 12, 2024
1 parent 599d4e2 commit 5754951
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/resourceloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ log = { workspace = true }
sl-std = { workspace = true }
http = { workspace = true }
error-derive = { workspace = true }
settings = { workspace = true }
# smol = { workspace = true }
# async-task = { workspace = true }
# serialize = { workspace = true }
Expand Down
9 changes: 8 additions & 1 deletion crates/resourceloader/src/resource.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use error_derive::Error;
use http::request::HTTPError;
use settings::SETTINGS;
use sl_std::{ascii, base64};
use std::{fs, io};
use url::URL;
Expand Down Expand Up @@ -93,7 +94,13 @@ impl Resource {
let resource = match url.scheme().as_str() {
"http" | "https" => {
// Fetch the file via http
let response = http::request::Request::get(url).send()?;
let mut request = http::request::Request::get(url);

if let Some(proxy) = dbg!(SETTINGS.proxy) {
request.set_proxy(proxy);
}

let response = request.send()?;

Self::new_for_http_request(response.body, response.headers)
},
Expand Down

0 comments on commit 5754951

Please sign in to comment.