pub struct HttpResponse<'a> {
pub status_code: StatusCode,
pub headers: Vec<HttpHeader<'a>, 16>,
pub body: ResponseBody<'a>,
}Expand description
HTTP Response struct with status code, headers and body
This struct represents the response received from an HTTP server. It contains the status code, headers, and the response body which can be either text or binary data using zero-copy references.
Fieldsยง
ยงstatus_code: StatusCodeThe HTTP status code (e.g., 200 for OK, 404 for Not Found)
headers: Vec<HttpHeader<'a>, 16>A collection of response headers with both names and values
body: ResponseBody<'a>The response body that can handle both text and binary data
Implementationsยง
Sourceยงimpl HttpResponse<'_>
impl HttpResponse<'_>
Sourcepub fn get_header(&self, name: &str) -> Option<&str>
pub fn get_header(&self, name: &str) -> Option<&str>
Get a header value by name (case-insensitive)
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Get the Content-Type header value
Sourcepub fn content_length(&self) -> Option<usize>
pub fn content_length(&self) -> Option<usize>
Get the Content-Length header value as a number
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if the response indicates success (2xx status codes)
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Check if the response is a client error (4xx status codes)
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if the response is a server error (5xx status codes)
Sourcepub fn build_bytes<const MAX_RESPONSE_SIZE: usize>(
&self,
) -> Vec<u8, MAX_RESPONSE_SIZE>
pub fn build_bytes<const MAX_RESPONSE_SIZE: usize>( &self, ) -> Vec<u8, MAX_RESPONSE_SIZE>
Build HTTP response bytes from this HttpResponse