use bytes::Bytes;
use futures::Stream;
use reqwest::{Client, Error};
use std::{sync::LazyLock, time::Duration};
use url::Url;
static CLIENT: LazyLock<Client> = LazyLock::new(|| {
reqwest::Client::builder()
.gzip(true) .timeout(Duration::from_secs(5))
.user_agent(concat!(
env!("CARGO_PKG_NAME"),
"/",
env!("CARGO_PKG_VERSION")
))
.build()
.expect("should be able to build client")
});
pub async fn stream_poison(
poison_source: &Url,
) -> Result<impl Stream<Item = Result<Bytes, Error>>, Error> {
let stream = CLIENT
.get(poison_source.clone())
.send()
.await?
.error_for_status()?
.bytes_stream();
Ok(stream)
}