pub struct HttpChunkResponse<'r, R> {
pub reader: Pin<&'r mut R>,
pub chunk_size: usize,
pub max_age: Option<u32>,
pub cache_private: Option<bool>,
pub headers: Option<Vec<HttpHeader>>,
}Expand description
Represents a chunked HTTP response for streaming large bodies of data.
This is used when the response body is too large to fit in memory or is generated on-the-fly.
Fields§
§reader: Pin<&'r mut R>A pinned, mutable reference to an async reader that provides the body data.
chunk_size: usizeThe suggested size for each data chunk. Defaults to DEFAULT_BUF_SIZE.
max_age: Option<u32>Cache control max-age setting for the response.
cache_private: Option<bool>Cache control privacy setting for the response.
headers: Option<Vec<HttpHeader>>Additional headers to include in the response.
Implementations§
Source§impl<'r, R> HttpChunkResponse<'r, R>
impl<'r, R> HttpChunkResponse<'r, R>
Sourcepub fn new(r: &'r mut R) -> Self
pub fn new(r: &'r mut R) -> Self
Creates a new HttpChunkResponse with a given reader and default settings.
Sourcepub fn get_response_header(&self) -> Result<ResponseHeader>
pub fn get_response_header(&self) -> Result<ResponseHeader>
Builds the ResponseHeader for the chunked response.
This will include a Transfer-Encoding: chunked header.
Auto Trait Implementations§
impl<'r, R> Freeze for HttpChunkResponse<'r, R>
impl<'r, R> RefUnwindSafe for HttpChunkResponse<'r, R>where
R: RefUnwindSafe,
impl<'r, R> Send for HttpChunkResponse<'r, R>where
R: Send,
impl<'r, R> Sync for HttpChunkResponse<'r, R>where
R: Sync,
impl<'r, R> Unpin for HttpChunkResponse<'r, R>
impl<'r, R> UnsafeUnpin for HttpChunkResponse<'r, R>
impl<'r, R> !UnwindSafe for HttpChunkResponse<'r, R>
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