mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-16 18:59:55 +00:00
63ad786768
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
19 lines
459 B
Rust
19 lines
459 B
Rust
//! Sends an HTTP request to the Rust website.
|
|
|
|
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(())
|
|
})
|
|
}
|