use futures_lite::StreamExt;
use futures_lite::future::block_on;
fn main() -> Result<(), Box<dyn std::error::Error>> {
block_on(async move {
let client = ugi::Client::builder().build()?;
let res = client
.get("https://stream.example.com/events")
.header("accept", "text/event-stream")?
.await?;
let mut body = res.bytes_stream();
while let Some(chunk) = body.next().await {
let chunk = chunk?;
print!("{}", String::from_utf8_lossy(&chunk));
}
Ok(())
})
}