2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-02-20 19:29:40 +00:00
async-std/examples/surf-web.rs

22 lines
485 B
Rust
Raw Normal View History

2019-08-15 15:03:39 +00:00
//! Creates a web request to the Rust website.
#![feature(async_await)]
use async_std::task;
fn main() -> Result<(), surf::Exception> {
task::block_on(async {
let url = "https://www.rust-lang.org";
let mut response = surf::get(url).await?;
let body = response.body_string().await?;
dbg!(url);
dbg!(response.status());
dbg!(response.version());
dbg!(response.headers());
dbg!(body.len());
Ok(())
})
}