Skip to content

Commit

Permalink
Merge pull request #455 from cyqsimon/ureq-proxy
Browse files Browse the repository at this point in the history
Enable proxy detection when using `ureq` as HTTP client
  • Loading branch information
ramsayleung authored Jan 29, 2024
2 parents 149fb96 + 602aa55 commit 80caeac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rspotify-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ thiserror = "1.0.29"

# Supported clients
reqwest = { version = "0.11.4", default-features = false, features = ["json", "socks"], optional = true }
ureq = { version = "2.2.0", default-features = false, features = ["json", "cookies"], optional = true }
ureq = { version = "2.2.0", default-features = false, features = ["json", "cookies", "socks-proxy"], optional = true }

[dev-dependencies]
tokio = { version = "1.11.0", features = ["macros", "rt-multi-thread"] }
Expand Down
1 change: 1 addition & 0 deletions rspotify-http/src/ureq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct UreqClient {
impl Default for UreqClient {
fn default() -> Self {
let agent = ureq::AgentBuilder::new()
.try_proxy_from_env(true)
.timeout(Duration::from_secs(10))
.build();
Self { agent }
Expand Down
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@
//!
//! ### Proxies
//!
//! [reqwest supports system proxies by default][reqwest-proxies]. It reads the
//! environment variables `HTTP_PROXY` and `HTTPS_PROXY` environmental variables
//! to set HTTP and HTTPS proxies, respectively.
//! Both [reqwest][reqwest-proxies] and [ureq][ureq-proxying] support system
//! proxies by default. They both read `http_proxy`, `https_proxy`, `all_proxy`
//! and their uppercase variants `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`,
//! although the specific logic implementations are a little different.
//!
//! See also:
//! - [reqwest](https://docs.rs/reqwest/latest/src/reqwest/proxy.rs.html#897-920)
//! - [ureq](https://docs.rs/ureq/latest/src/ureq/proxy.rs.html#73-95)
//!
//! ### Environmental variables
//!
Expand Down

0 comments on commit 80caeac

Please sign in to comment.