Making Requests
Make a HTTP GET request
Parses the supplied URL and makes a synchronous HTTP GET request
with reqwest::blocking::get. Prints obtained reqwest::blocking::Response
status and headers. Reads HTTP response body into an allocated String
using read_to_string.
#![allow(unused)] fn main() { {{include examples/web_request_sync_get.rs}} }
Async
A similar approach can be used by including the tokio executor
to make the main function asynchronous, retrieving the same information.
In this example, tokio::main handles all the heavy executor setup
and allows sequential code implemented without blocking until .await.
Uses the asynchronous versions of reqwest, both reqwest::get and
reqwest::Response.
#![allow(unused)] fn main() { {{include examples/web_request_async_get.rs}} }