Skip to main content

eventsrc_client/reqwest/
mod.rs

1mod request;
2mod response;
3
4pub(crate) use request::freeze_request;
5pub(crate) use response::{into_body_stream, validate_response};
6
7use crate::{error::Error, oneshot, replayable};
8
9const SSE_CONTENT_TYPE: &str = "text/event-stream";
10const LAST_EVENT_ID_HEADER: &str = "Last-Event-ID";
11
12impl oneshot::EventSourceExt for ::reqwest::Response {
13    fn event_source(self) -> Result<oneshot::EventSource, Error> {
14        validate_response(&self)?;
15        Ok(oneshot::EventSource::new(into_body_stream(self)))
16    }
17}
18
19impl replayable::EventSourceExt for ::reqwest::RequestBuilder {
20    fn event_source(self) -> Result<replayable::EventSource, Error> {
21        Ok(replayable::EventSource::new(freeze_request(self)?))
22    }
23}