Talking to the network
Almost every useful Rust program talks to something over HTTP, and reqwest is what it talks
with. The first request is four lines; the rest of the chapter is what happens when the network is
not perfect.
Timeouts, retries, redirects, a body you have to read before you can see the error — all of it.
Articles
Section titled “Articles”- How to make a GET requestreqwest, the runtime it needs, and the text you get back
- How to POST JSON to an APIa serde struct in, a status code out
- How to set a timeout on a requestthe default that is no timeout at all
- How to read a response headerheaders, case, and the rate limit you should respect
- How to handle a non-200 statuserror_for_status, and reading the body anyway
- How to retry a failed requestbackoff, and the requests you must not retry
- How to make several requests at oncejoin_all, and the concurrency limit you forgot
- How to parse JSON from an APIserde into a struct, and the field that is sometimes null
- How to download a file over HTTPstreaming to disk instead of into memory
- How to parse a URLthe url crate, and the parts it hands you
- How to fix a TLS certificate errorthe three causes, and why not to disable verification
- How to send an email from a Rust programSMTP, credentials, and why to use an API instead