async-std/examples/surf-web.rs
Stjepan Glavina e9e3754402
Add Surf example (#78)
* Add Surf example

* Use a different osx image
2019-08-18 19:14:27 +02:00

21 lines
485 B
Rust

//! Sends an HTTP 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(())
})
}