Skip to content

Commit

Permalink
Merge pull request #471 from jirutka/ureq-native-tls
Browse files Browse the repository at this point in the history
Fix ureq-native-tls feature to actually use native-tls
  • Loading branch information
ramsayleung authored Apr 1, 2024
2 parents 57718a5 + e3e9d2b commit 38b95b8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
features:
- rspotify/cli,rspotify/env-file,rspotify/client-ureq,rspotify/ureq-rustls-tls,rspotify-http/client-ureq,rspotify-http/ureq-rustls-tls
- rspotify/cli,rspotify/env-file,rspotify/client-reqwest,rspotify/reqwest-rustls-tls,rspotify-http/client-reqwest,rspotify-http/reqwest-rustls-tls
- rspotify/cli,rspotify/env-file,rspotify/client-ureq,rspotify/ureq-native-tls,rspotify-http/client-ureq,rspotify-http/ureq-native-tls
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand All @@ -80,6 +81,10 @@ jobs:
override: true
components: clippy

- name: Install libssl-dev
if: ${{ contains(matrix.features, 'ureq-native-tls') }}
run: sudo apt-get install libssl-dev

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -117,4 +122,4 @@ jobs:
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Run wasm-pack test
run: wasm-pack test --node
run: wasm-pack test --node
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.13.1 (Unreleased)

**Bugfixes**
- ([#471](https://github.com/ramsayleung/rspotify/pull/471)) Fix `ureq-native-tls` feature to actually use native-tls

## 0.13.0 (2024.03.08)

**New features**
Expand Down
3 changes: 2 additions & 1 deletion rspotify-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ thiserror = "1.0.29"
# Supported clients
reqwest = { version = "0.12.1", default-features = false, features = ["json", "socks"], optional = true }
ureq = { version = "2.2.0", default-features = false, features = ["json", "cookies", "socks-proxy"], optional = true }
native-tls = { version = "0.2.11", optional = true }

[dev-dependencies]
tokio = { version = "1.11.0", features = ["macros", "rt-multi-thread"] }
Expand All @@ -47,7 +48,7 @@ reqwest-native-tls-vendored = ["reqwest/native-tls-vendored"]
# Same for ureq.
ureq-rustls-tls = ["ureq/tls"]
ureq-rustls-tls-native-certs = ["ureq/tls", "ureq/native-certs"]
ureq-native-tls = ["ureq/native-tls"]
ureq-native-tls = ["ureq/native-tls", "dep:native-tls"]

# Internal features for checking async or sync compilation
__async = ["async-trait"]
Expand Down
13 changes: 10 additions & 3 deletions rspotify-http/src/ureq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ 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 }
.timeout(Duration::from_secs(10));

#[cfg(feature = "ureq-native-tls")]
let agent = agent.tls_connector(std::sync::Arc::new(
native_tls::TlsConnector::new().expect("Failed to initialize TLS connector"),
));

Self {
agent: agent.build(),
}
}
}

Expand Down

0 comments on commit 38b95b8

Please sign in to comment.