pub struct HttpStreamResponse {
pub status: StatusCode,
pub headers: HeaderMap,
pub url: Url,
/* private fields */
}Expand description
HTTP response metadata plus a lazy body stream (from crate::HttpClient::execute_stream).
Fields§
§status: StatusCodeHTTP status code of the first response line.
headers: HeaderMapResponse headers available before consuming the body.
url: UrlEffective URL after redirects.
Implementations§
Source§impl HttpStreamResponse
impl HttpStreamResponse
Sourcepub fn new(
status: StatusCode,
headers: HeaderMap,
url: Url,
stream: HttpByteStream,
) -> Self
pub fn new( status: StatusCode, headers: HeaderMap, url: Url, stream: HttpByteStream, ) -> Self
Wraps status, headers, URL, and the byte stream.
§Parameters
status: HTTP status.headers: Header map.url: Final URL.stream: Pinned body stream.
§Returns
New HttpStreamResponse.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Sourcepub fn into_stream(self) -> HttpByteStream
pub fn into_stream(self) -> HttpByteStream
Sourcepub fn decode_events(self) -> SseEventStream
pub fn decode_events(self) -> SseEventStream
Decodes current stream body as SSE events (UTF-8 lines -> SSE frames).
§Returns
Stream yielding parsed SSE events.
§Errors
Each emitted item may contain:
- transport/read errors forwarded from the underlying HTTP stream;
crate::HttpError::sse_protocolwhen SSE line UTF-8 decoding fails.
Sourcepub fn decode_events_with_limits(
self,
max_line_bytes: usize,
max_frame_bytes: usize,
) -> SseEventStream
pub fn decode_events_with_limits( self, max_line_bytes: usize, max_frame_bytes: usize, ) -> SseEventStream
Decodes current stream body as SSE events with explicit line/frame size limits.
§Parameters
max_line_bytes: Maximum allowed bytes for one SSE line.max_frame_bytes: Maximum allowed bytes for one SSE frame.
§Returns
Stream yielding parsed SSE events.
§Errors
Each emitted item may contain transport/read/protocol errors and limit violations.
Sourcepub fn decode_json_chunks<T>(
self,
done_policy: DoneMarkerPolicy,
) -> SseChunkStream<T>where
T: DeserializeOwned + Send + 'static,
pub fn decode_json_chunks<T>(
self,
done_policy: DoneMarkerPolicy,
) -> SseChunkStream<T>where
T: DeserializeOwned + Send + 'static,
Decodes SSE data: payloads as JSON chunks with response defaults.
§Parameters
done_policy: Done marker policy (for example[DONE]).
§Type parameters
T: Target chunk type deserialized from eachdata:payload.
§Returns
Stream yielding crate::sse::SseChunk::Data and optional
crate::sse::SseChunk::Done.
§Errors
The stream may emit transport/protocol errors. Malformed JSON behavior is controlled by
the response default JSON mode (configured by crate::HttpClientOptions::sse_json_mode).
Sourcepub fn decode_json_chunks_with_mode<T>(
self,
done_policy: DoneMarkerPolicy,
mode: SseJsonMode,
) -> SseChunkStream<T>where
T: DeserializeOwned + Send + 'static,
pub fn decode_json_chunks_with_mode<T>(
self,
done_policy: DoneMarkerPolicy,
mode: SseJsonMode,
) -> SseChunkStream<T>where
T: DeserializeOwned + Send + 'static,
Decodes SSE data: payloads as JSON chunks with configurable strictness.
§Parameters
done_policy: Done marker policy (for example[DONE]).mode: JSON decoding strictness for malformed payloads.
§Type parameters
T: Target chunk type deserialized from eachdata:payload.
§Returns
Stream yielding crate::sse::SseChunk::Data and optional
crate::sse::SseChunk::Done.
§Errors
- transport/read errors from underlying stream;
- protocol errors from SSE parsing;
- in strict mode,
crate::HttpError::sse_decodeon malformed JSON payload.
Sourcepub fn decode_json_chunks_with_mode_and_limits<T>(
self,
done_policy: DoneMarkerPolicy,
mode: SseJsonMode,
max_line_bytes: usize,
max_frame_bytes: usize,
) -> SseChunkStream<T>where
T: DeserializeOwned + Send + 'static,
pub fn decode_json_chunks_with_mode_and_limits<T>(
self,
done_policy: DoneMarkerPolicy,
mode: SseJsonMode,
max_line_bytes: usize,
max_frame_bytes: usize,
) -> SseChunkStream<T>where
T: DeserializeOwned + Send + 'static,
Decodes SSE data: payloads as JSON chunks with configurable strictness and limits.
§Parameters
done_policy: Done marker policy (for example[DONE]).mode: JSON decoding strictness for malformed payloads.max_line_bytes: Maximum allowed bytes for one SSE line.max_frame_bytes: Maximum allowed bytes for one SSE frame.
§Type parameters
T: Target chunk type deserialized from eachdata:payload.
§Returns
Stream yielding crate::sse::SseChunk::Data and optional
crate::sse::SseChunk::Done.