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

19 lines
459 B
Rust
Raw Normal View History

use async_std::task;
2020-10-20 12:45:37 +00:00
fn main() -> Result<(), surf::Error> {
task::block_on(async {
let url = "https://www.rust-lang.org";
2020-10-20 12:45:37 +00:00
let mut response = surf::get(url).send().await?;
let body = response.body_string().await?;
dbg!(url);
dbg!(response.status());
dbg!(response.version());
2020-10-20 12:45:37 +00:00
dbg!(response.header_names());
dbg!(response.header_values());
dbg!(body.len());
Ok(())
})
}