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