fix: enable reqwest default-tls feature in transport-http #248
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Reqwest has
default-tls
as a default feature (https://docs.rs/reqwest/latest/reqwest/#optional-features), however alloy crates import dependencies withdefault-features = false
.The
alloy
metadata crate hasdefault-tls
as its default feature, which in turn enables this feature in reqwest, so connections using tls via https work fine when using thealloy
crate.However,
alloy-providers
,alloy-rpc-client
, andalloy-transport-http
also depend on reqwest, but provide no option to enabledefault-tls
. So if these crates are used directly (instead of egalloy::alloy_providers
) then it will panic when trying to connect to a https url.Solution
The simplest fix was to add this to the reqwest feature (default) in the
alloy-transport-http
cargo toml.Both
alloy-providers
andalloy-rpc-client
also enablealloy-transport-http/reqwest
by default, so this enables the reqwest feature for those crates as well.To confirm the fix:
alloy/crates/rpc-client/tests/it/http.rs
Lines 5 to 15 in 86027c9
#[tokio::test]
HTTP_PROVIDER_URL=https://rpc.ankr.com/eth cargo test --package alloy-rpc-client -- http::it_makes_a_request --exact
Test passes successfully vs the previous panic in the linked issue.
Fixes #247
PR Checklist