use bouillon::{SessionExt as _, glib};
use soup::prelude::*;
async fn request() -> bouillon::Result<()> {
let session = soup::Session::new();
session.set_user_agent("buillon-example");
let robots_txt = session
.get("https://httpbin.org/robots.txt_")
.send()
.await?
.error_for_status()?
.text()
.await?;
print!("{robots_txt}");
Ok(())
}
fn main() {
let c = glib::MainContext::default();
let l = glib::MainLoop::new(Some(&c), false);
c.spawn_local(async {
if let Err(err) = request().await {
eprintln!("error: {err}");
}
});
l.run();
}