pub struct HttpResponseBuilder { /* private fields */ }Expand description
Builder for HTTP/1.x response messages.
Default values:
- version :
HTTP/1.1 - status code:
200 - reason :
OK - headers : empty
- body : empty
Implementations§
Source§impl HttpResponseBuilder
impl HttpResponseBuilder
Sourcepub fn status(self, code: u16, reason: &str) -> Self
pub fn status(self, code: u16, reason: &str) -> Self
Set the status code and reason phrase together.
§Example
use stackforge_core::layer::http::builder::HttpResponseBuilder;
let bytes = HttpResponseBuilder::new()
.status(404, "Not Found")
.build();
assert!(bytes.starts_with(b"HTTP/1.1 404 Not Found\r\n"));Sourcepub fn header(self, name: &str, value: &str) -> Self
pub fn header(self, name: &str, value: &str) -> Self
Append a response header.
Headers are written in the order they are added. No deduplication is performed.
Trait Implementations§
Source§impl Clone for HttpResponseBuilder
impl Clone for HttpResponseBuilder
Source§fn clone(&self) -> HttpResponseBuilder
fn clone(&self) -> HttpResponseBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpResponseBuilder
impl Debug for HttpResponseBuilder
Auto Trait Implementations§
impl Freeze for HttpResponseBuilder
impl RefUnwindSafe for HttpResponseBuilder
impl Send for HttpResponseBuilder
impl Sync for HttpResponseBuilder
impl Unpin for HttpResponseBuilder
impl UnsafeUnpin for HttpResponseBuilder
impl UnwindSafe for HttpResponseBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more