pub struct ScriptedResponse {
pub status: u16,
pub headers: BTreeMap<String, String>,
pub chunks: Vec<ResponseChunk>,
pub disconnect: bool,
}Expand description
A streamed HTTP response, optionally disconnected before its terminator.
Fields§
§status: u16HTTP status code.
headers: BTreeMap<String, String>Response headers.
chunks: Vec<ResponseChunk>Ordered chunked-transfer body fragments.
disconnect: boolClose the socket without a final zero-sized chunk.
Implementations§
Source§impl ScriptedResponse
impl ScriptedResponse
Sourcepub fn ok(chunks: Vec<ResponseChunk>) -> Self
pub fn ok(chunks: Vec<ResponseChunk>) -> Self
Creates a successful response.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Adds or replaces a response header.
Sourcepub const fn disconnect_after_chunks(self) -> Self
pub const fn disconnect_after_chunks(self) -> Self
Disconnects after the configured chunks, simulating a broken stream.
Trait Implementations§
Source§impl Clone for ScriptedResponse
impl Clone for ScriptedResponse
Source§fn clone(&self) -> ScriptedResponse
fn clone(&self) -> ScriptedResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ScriptedResponse
impl RefUnwindSafe for ScriptedResponse
impl Send for ScriptedResponse
impl Sync for ScriptedResponse
impl Unpin for ScriptedResponse
impl UnsafeUnpin for ScriptedResponse
impl UnwindSafe for ScriptedResponse
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