diff --git a/crates/mev-share-sse/src/client.rs b/crates/mev-share-sse/src/client.rs index a41ba77..a54f518 100644 --- a/crates/mev-share-sse/src/client.rs +++ b/crates/mev-share-sse/src/client.rs @@ -8,7 +8,7 @@ use futures_util::{ Stream, TryFutureExt, TryStreamExt, }; use pin_project_lite::pin_project; -use reqwest::header::{self, HeaderMap, HeaderValue}; +use reqwest::header::{self, HeaderValue}; use serde::{de::DeserializeOwned, Serialize}; use std::{ future::Future, @@ -166,15 +166,7 @@ impl EventClient { impl Default for EventClient { fn default() -> Self { - Self::new( - reqwest::Client::builder() - .default_headers(HeaderMap::from_iter([ - (header::ACCEPT, HeaderValue::from_static("text/event-stream")), - (header::CACHE_CONTROL, HeaderValue::from_static("no-cache")), - ])) - .build() - .expect("Reqwest client build failed, TLS backend not available?"), - ) + Self::new(Default::default()) } } @@ -352,12 +344,16 @@ impl Stream for ActiveEventStream { } } +/// Creates a new SSE stream. async fn new_stream( client: &reqwest::Client, endpoint: &str, query: Option, ) -> reqwest::Result> { - let mut builder = client.get(endpoint); + let mut builder = client + .get(endpoint) + .header(header::ACCEPT, HeaderValue::from_static("text/event-stream")) + .header(header::CACHE_CONTROL, HeaderValue::from_static("no-cache")); if let Some(query) = query { builder = builder.query(&query); } @@ -409,10 +405,10 @@ mod tests { const HISTORY_INFO_V1: &str = "https://mev-share.flashbots.net/api/v1/history/info"; fn init_tracing() { - tracing_subscriber::registry() + let _ = tracing_subscriber::registry() .with(fmt::layer()) .with(EnvFilter::from_default_env()) - .init(); + .try_init(); } #[tokio::test]