Requests using proxy settings from ENV

master
jjy 7 months ago
parent 62ab39cf82
commit eaf32bbd12
  1. 12
      Cargo.lock
  2. 2
      Cargo.toml
  3. 5
      src/install/krate.rs
  4. 1
      src/manifest/mod.rs
  5. 15
      src/test/webdriver/chromedriver.rs
  6. 14
      src/test/webdriver/geckodriver.rs

12
Cargo.lock generated

@ -1452,6 +1452,17 @@ version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "socks"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b"
dependencies = [
"byteorder",
"libc",
"winapi",
]
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.9.8" version = "0.9.8"
@ -1682,6 +1693,7 @@ dependencies = [
"rustls-webpki", "rustls-webpki",
"serde", "serde",
"serde_json", "serde_json",
"socks",
"url", "url",
"webpki-roots", "webpki-roots",
] ]

@ -32,7 +32,7 @@ siphasher = "0.3.10"
strsim = "0.10.0" strsim = "0.10.0"
clap = { version = "4.2.5", features = ["derive"] } clap = { version = "4.2.5", features = ["derive"] }
toml = "0.7.3" toml = "0.7.3"
ureq = { version = "2.6.2", features = ["json"] } ureq = { version = "2.6.2", features = ["json", "socks-proxy"] }
walkdir = "2.3.2" walkdir = "2.3.2"
which = "4.4.0" which = "4.4.0"
path-clean = "1.0.1" path-clean = "1.0.1"

@ -17,7 +17,10 @@ pub struct KrateResponse {
impl Krate { impl Krate {
pub fn new(name: &Tool) -> Result<Krate> { pub fn new(name: &Tool) -> Result<Krate> {
let krate_address = format!("https://crates.io/api/v1/crates/{}", name); let krate_address = format!("https://crates.io/api/v1/crates/{}", name);
let res = ureq::get(&krate_address) let res = ureq::builder()
.try_proxy_from_env(true)
.build()
.get(&krate_address)
.set( .set(
"user-agent", "user-agent",
&format!("wasm-pack/{}", VERSION.unwrap_or("unknown")), &format!("wasm-pack/{}", VERSION.unwrap_or("unknown")),

@ -227,6 +227,7 @@ impl Crate {
fn check_wasm_pack_latest_version() -> Result<Crate> { fn check_wasm_pack_latest_version() -> Result<Crate> {
let url = "https://crates.io/api/v1/crates/wasm-pack"; let url = "https://crates.io/api/v1/crates/wasm-pack";
let agent = ureq::builder() let agent = ureq::builder()
.try_proxy_from_env(true)
.user_agent(&format!( .user_agent(&format!(
"wasm-pack/{} ({})", "wasm-pack/{} ({})",
WASM_PACK_VERSION.unwrap_or_else(|| "unknown"), WASM_PACK_VERSION.unwrap_or_else(|| "unknown"),

@ -134,13 +134,14 @@ struct GoodLatestVersions {
/// Retrieve the latest version of chromedriver from the json endpoints. /// Retrieve the latest version of chromedriver from the json endpoints.
/// See: <https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints> /// See: <https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints>
fn fetch_chromedriver_version() -> Result<String> { fn fetch_chromedriver_version() -> Result<String> {
let info: GoodLatestVersions = ureq::get( let info: GoodLatestVersions = ureq::builder()
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json", .try_proxy_from_env(true)
) .build()
.call() .get("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
.context("fetching of chromedriver's LATEST_RELEASE failed")? .call()
.into_json() .context("fetching of chromedriver's LATEST_RELEASE failed")?
.context("converting chromedriver version response to GoodLatestVersions failed")?; .into_json()
.context("converting chromedriver version response to GoodLatestVersions failed")?;
let version = info let version = info
.channels .channels

@ -141,12 +141,14 @@ fn should_load_geckodriver_version_from_stamp(json: &serde_json::Value) -> bool
} }
fn fetch_latest_geckodriver_tag_json() -> Result<String> { fn fetch_latest_geckodriver_tag_json() -> Result<String> {
let content: serde_json::Value = let content: serde_json::Value = ureq::builder()
ureq::get("https://github.com/mozilla/geckodriver/releases/latest") .try_proxy_from_env(true)
.set("Accept", "application/json") .build()
.call() .get("https://github.com/mozilla/geckodriver/releases/latest")
.context("fetching of geckodriver's latest release data failed")? .set("Accept", "application/json")
.into_json()?; .call()
.context("fetching of geckodriver's latest release data failed")?
.into_json()?;
get_version_from_json(content) get_version_from_json(content)
} }

Loading…
Cancel
Save