mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-30 18:44:35 +01:00
6f0a6bd1bb
For intrepid commit message readers: The choice to add allows for the inlined format args lint instead of actually inlining them is not very clear because our actual real world MSRV is not clear. We currently claim 1.60 is our MSRV but this is mainly due to dependencies. I'm fairly sure that we could support < 1.58 if those deps are outdated in a users lockfile. We'll remove these allows again at some point soon.
30 lines
734 B
Rust
30 lines
734 B
Rust
#![allow(clippy::uninlined_format_args)]
|
|
|
|
use std::error::Error as StdError;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn StdError>> {
|
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
|
|
|
// construct request builder
|
|
let client = awc::Client::new();
|
|
|
|
// configure request
|
|
let request = client
|
|
.get("https://www.rust-lang.org/")
|
|
.append_header(("User-Agent", "Actix-web"));
|
|
|
|
println!("Request: {:?}", request);
|
|
|
|
let mut response = request.send().await?;
|
|
|
|
// server response head
|
|
println!("Response: {:?}", response);
|
|
|
|
// read response body
|
|
let body = response.body().await?;
|
|
println!("Downloaded: {:?} bytes", body.len());
|
|
|
|
Ok(())
|
|
}
|