diff --git a/Cargo.toml b/Cargo.toml index 7891057d..45149ad7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,5 +35,5 @@ slab = "0.4.2" [dev-dependencies] femme = "1.1.0" -# surf = { git = "ssh://github.com/yoshuawuyts/surf" } +surf = "1.0.1" tempdir = "0.3.7" diff --git a/examples/fetch-html.rs b/examples/fetch-html.rs deleted file mode 100644 index e1482214..00000000 --- a/examples/fetch-html.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Fetches the HTML contents of the Rust website. - -#![feature(async_await)] - -use std::error::Error; - -use async_std::task; - -fn main() -> Result<(), Box> { - task::block_on(async { - // let contents = surf::get("https://www.rust-lang.org").recv_string().await?; - // println!("{}", contents); - Ok(()) - }) -} diff --git a/examples/surf-web.rs b/examples/surf-web.rs new file mode 100644 index 00000000..e016b089 --- /dev/null +++ b/examples/surf-web.rs @@ -0,0 +1,21 @@ +//! 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(()) + }) +}