reqwest-sse
A lightweight Rust library that adds Server-Sent Events support to the reqwest HTTP client.
Repository Health
Technical Analysis
reqwest-sse is a small Rust library that extends the popular reqwest HTTP client with native support for Server-Sent Events (SSE). It introduces an EventSource trait that adds an ergonomic .events() method to reqwest’s Response, turning the response body into an asynchronous stream of parsed SSE Events.
Because it plugs directly into the familiar reqwest and StreamExt APIs, it lets you consume real-time event streams (LLM token streams, live notifications, log tails) without pulling in a separate client or writing your own SSE parser.
What You Get
- An
EventSourcetrait that adds a.events()method to reqwest’sResponse - An async
Streamof parsed SSEEvents consumable withStreamExt - A structured
Eventtype exposing event_type, data, last_event_id, and retry fields - Up-front validation of HTTP status and
text/event-streamcontent type with typed errors - Seamless integration with the existing reqwest client and Tokio async runtime
Common Use Cases
- Consuming streaming LLM/chat completion responses delivered as SSE
- Subscribing to real-time notifications or live updates from an HTTP endpoint
- Tailing server logs or progress events pushed over an event stream
- Adding real-time features to an existing reqwest-based client without a new dependency stack
Under The Hood
Architecture - The crate is two small files: lib.rs defines the Event struct, the EventSource trait and its impl for reqwest’s Response, and the parsing that splits the byte stream into field: value lines and assembles them into events; error.rs holds the EventSourceError/EventError types. .events() first checks the status is 200 OK and the Content-Type is text/event-stream, then wraps the response body in an async_stream generator that yields parsed events. Tech Stack - Rust edition 2024 (MSRV 1.85) built on reqwest 0.13 (http2 + stream), async-stream, and Tokio’s stream/util crates for the async plumbing. Code Quality - Despite being under 300 lines, it includes unit tests for the SSE line-parsing logic and returns descriptive, typed errors rather than panicking. API Design - The extension-trait pattern makes adoption a single .events() call on an existing reqwest response, and the returned stream uses the standard StreamExt interface Rust async developers already know.