You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the current stable rust (1.66; on macOS 11.7.1), the ch8/ch8-simple example does not run (at least on a system with IPv4 and IPv6 addresses on the client), with a typical run attempt ending with:
Compiling ch8-simple v0.1.0 (/Users/ewen/misc/src/rust/rust-in-action/code/ch8/ch8-simple)
Finished dev [unoptimized + debuginfo] target(s) in 26.35s
Running `target/debug/ch8-simple`
Error: Error(Hyper(Error(Connect, Os { code: 22, kind: InvalidInput, message: "Invalid argument" })), "http://www.rustinaction.com/")
After trying a few other example websites sites (my own, http://httpforever.com/ in case it was the HTTPS redirect, etc) I eventually concluded I wasn't going to get the very old reqwest version (0.9) working on rust 1.66 on my system. FTR, I managed to get a few different errors depending on the site, including Os { code: 47, kind: Uncategorized, message: "Address family not supported by protocol family" } which I suspect is caused by trying to connect to IPv6 addresses via IPv4 sockets or similar, but nothing that seemed likely to work at all.
So I forward ported the example to reqwest 0.11, which now defaults to an asynchronous API (since 0.10.0), but does have an optional "blocking" API that works more like reqwest 0.9 still available if you explicitly depend on it.
In case someone else needs to do this, the change required are:
In Cargo.toml change the dependency to reqwest = { version = "0.11.13", features = ["blocking"] }
In src/main.rs change the call to the API to let response = reqwest::blocking::get(url)?; (the mut that was there removed because the compiler told me it wasn't necessary; possibly also a reqwest 0.11 API change)
FTR, I'm not making this a PR as I'm unclear how far back in rust versions reqwest 0.10 / 0.11 support, and this may just be a backwards / forwards incompatibility issue ("stable" rust isn't that stable, still). OTOH, reqwest 0.10.0, which introduced this feature was released over 3 years ago, so mabye it's time to update the example.
Either way, this is a New And Exciting (tm) way that the included examples don't work...
... and if this repo is every updated again, mabye it'd be worth updating to the reqwest 0.11 syntax, with a comment in the source in the repo about why it differs from the book text.
With the current stable rust (1.66; on macOS 11.7.1), the ch8/ch8-simple example does not run (at least on a system with IPv4 and IPv6 addresses on the client), with a typical run attempt ending with:
After trying a few other example websites sites (my own, http://httpforever.com/ in case it was the HTTPS redirect, etc) I eventually concluded I wasn't going to get the very old reqwest version (0.9) working on rust 1.66 on my system. FTR, I managed to get a few different errors depending on the site, including
Os { code: 47, kind: Uncategorized, message: "Address family not supported by protocol family" }
which I suspect is caused by trying to connect to IPv6 addresses via IPv4 sockets or similar, but nothing that seemed likely to work at all.So I forward ported the example to reqwest 0.11, which now defaults to an asynchronous API (since 0.10.0), but does have an optional "blocking" API that works more like reqwest 0.9 still available if you explicitly depend on it.
In case someone else needs to do this, the change required are:
In
Cargo.toml
change the dependency toreqwest = { version = "0.11.13", features = ["blocking"] }
In
src/main.rs
change the call to the API tolet response = reqwest::blocking::get(url)?;
(themut
that was there removed because the compiler told me it wasn't necessary; possibly also a reqwest 0.11 API change)FTR, I'm not making this a PR as I'm unclear how far back in rust versions reqwest 0.10 / 0.11 support, and this may just be a backwards / forwards incompatibility issue ("stable" rust isn't that stable, still). OTOH, reqwest 0.10.0, which introduced this feature was released over 3 years ago, so mabye it's time to update the example.
Either way, this is a New And Exciting (tm) way that the included examples don't work...
... and if this repo is every updated again, mabye it'd be worth updating to the reqwest 0.11 syntax, with a comment in the source in the repo about why it differs from the book text.
git diff of changes to use reqwest 0.11
The text was updated successfully, but these errors were encountered: