get/
get.rs

1use http_req::request;
2
3fn main() {
4    // Container for body of a response.
5    let mut body = Vec::new();
6
7    // Sends a HTTP GET request and processes the response. Saves body of the response to `body` variable.
8    let res = request::get("https://www.rust-lang.org/learn", &mut body).unwrap();
9
10    //Prints details about the response.
11    println!("Status: {} {}", res.status_code(), res.reason());
12    println!("Headers: {}", res.headers());
13    //println!("{}", String::from_utf8_lossy(&body));
14}