pub struct Response {
pub header: ResponseHeader,
pub body: Body,
}
Expand description
The response created from a server.
Fields§
§header: ResponseHeader
§body: Body
Implementations§
source§impl Response
impl Response
sourcepub fn new(header: ResponseHeader, body: Body) -> Response
pub fn new(header: ResponseHeader, body: Body) -> Response
Creates a new Response
.
sourcepub fn builder() -> ResponseBuilder
pub fn builder() -> ResponseBuilder
Creates a new Response
with a builder.
sourcepub fn header(&self) -> &ResponseHeader
pub fn header(&self) -> &ResponseHeader
Get the response header by reference.
sourcepub fn take_body(&mut self) -> Body
pub fn take_body(&mut self) -> Body
Takes the body replacing it with an empty one.
Note
If you used the builder to create a Response
you should probably reset the content-length
header.
pub fn text(body: impl Into<Body>) -> Response
pub fn html(body: impl Into<Body>) -> Response
Trait Implementations§
source§impl From<StatusCode> for Response
impl From<StatusCode> for Response
source§fn from(status_code: StatusCode) -> Response
fn from(status_code: StatusCode) -> Response
Converts to this type from the input type.