use ntex::client::{Client, error::ClientError};

#[ntex::main]
async fn main() -> Result<(), ClientError> {
    env_logger::init();

    let client = Client::new().await;

    // Create request builder, configure request and send
    let response = client
        .get("https://www.rust-lang.org/")
        .header("User-Agent", "ntex")
        .send()
        .await?;

    // server http response
    println!("Response: {:?}", response);

    // read response body
    let body = response.body().await.unwrap();
    println!("Downloaded: {:?} bytes", body.len());

    Ok(())
}
