pub struct StreamingResponse<S: Read + Write> {
pub status: u16,
pub headers: Vec<(String, String)>,
/* private fields */
}Expand description
A streamed response: status + headers, plus the reader positioned at the body.
The caller decides how to drain it — [into_body] to buffer (application/json)
or [sse] to pump it as an SSE event stream (text/event-stream). Owns the
underlying stream, matching the MCP client’s per-request connection model.
Fields§
§status: u16§headers: Vec<(String, String)>Implementations§
Source§impl<S: Read + Write> StreamingResponse<S>
impl<S: Read + Write> StreamingResponse<S>
pub fn header(&self, name: &str) -> Option<&str>
pub fn is_success(&self) -> bool
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
The lowercased Content-Type (media type only, params stripped).
Sourcepub fn is_event_stream(&self) -> bool
pub fn is_event_stream(&self) -> bool
true when the body is text/event-stream (Streamable HTTP SSE).
Sourcepub fn into_body(self) -> Result<Vec<u8>>
pub fn into_body(self) -> Result<Vec<u8>>
Buffer the whole body (capped), honoring Content-Length/chunked/close.
Sourcepub fn sse(self) -> SseReader<BufReader<S>>
pub fn sse(self) -> SseReader<BufReader<S>>
Consume into an SseReader to pump text/event-stream events.
Sourcepub fn into_reader(self) -> BufReader<S> ⓘ
pub fn into_reader(self) -> BufReader<S> ⓘ
Consume into the raw body reader — for a response that turned out NOT to
be an event stream (e.g. a peer that answered application/json).
Auto Trait Implementations§
impl<S> Freeze for StreamingResponse<S>
impl<S> RefUnwindSafe for StreamingResponse<S>where
BufReader<S>: RefUnwindSafe,
impl<S> Send for StreamingResponse<S>
impl<S> Sync for StreamingResponse<S>
impl<S> Unpin for StreamingResponse<S>
impl<S> UnsafeUnpin for StreamingResponse<S>where
BufReader<S>: UnsafeUnpin,
impl<S> UnwindSafe for StreamingResponse<S>where
BufReader<S>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more