pub struct HttpResponseText { /* private fields */ }
Expand description
A struct representing an HTTP response.
This struct contains all the components of an HTTP response: the HTTP version, status code, status text, headers, and body. It is used to model and manipulate HTTP responses within the application.
§Fields
http_version
: A string representing the HTTP version (e.g., “HTTP/1.1”).status_code
: The HTTP status code (e.g., 200 for OK, 404 for Not Found).status_text
: A string containing the status text associated with the status code (e.g., “OK”, “Not Found”).headers
: AHashMap<String, String>
containing the headers of the response, where each key is the header name (e.g., “Content-Type”), and the value is the corresponding header value.body
: AVec<u8>
representing the body of the HTTP response, which contains the content being returned.
Implementations§
Source§impl HttpResponseText
impl HttpResponseText
Sourcepub fn get_http_version(&self) -> HttpVersion
pub fn get_http_version(&self) -> HttpVersion
Sourcepub fn get_status_code(&self) -> ResponseStatusCode
pub fn get_status_code(&self) -> ResponseStatusCode
Sourcepub fn get_status_text(&self) -> String
pub fn get_status_text(&self) -> String
Sourcepub fn get_headers(&self) -> ResponseHeaders
pub fn get_headers(&self) -> ResponseHeaders
Sourcepub fn get_body(&self) -> RequestBodyString
pub fn get_body(&self) -> RequestBodyString
Retrieves the body content of the HTTP response as a String
.
This method attempts to read the body of the response. If the body can be successfully read,
it is converted into a String
and returned. If reading the body fails, an empty string is returned.
§Returns
RequestBodyString
: The body of the response as a string. If the body could not be read, an empty string is returned. Gets the HTTP response body.
§Returns
RequestBodyString
- The response body.
Trait Implementations§
Source§impl Clone for HttpResponseText
impl Clone for HttpResponseText
Source§fn clone(&self) -> HttpResponseText
fn clone(&self) -> HttpResponseText
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for HttpResponseText
impl Debug for HttpResponseText
Source§impl Default for HttpResponseText
Default implementation for HttpResponseText.
impl Default for HttpResponseText
Default implementation for HttpResponseText.
§Returns
HttpResponseText
- Default initialized HttpResponseText.
Source§impl ResponseTrait for HttpResponseText
Implements the ResponseTrait
trait for HttpResponseText
.
impl ResponseTrait for HttpResponseText
Implements the ResponseTrait
trait for HttpResponseText
.
This implementation allows HttpResponseText
to convert between text and binary
representations of HTTP responses. It provides methods for parsing raw responses, as well
as accessing text and binary formats.
§Associated Types
OutputText
: Specifies the text representation of an HTTP response (HttpResponseText
).OutputBinary
: Specifies the binary representation of an HTTP response (HttpResponseBinary
).
Source§fn text(&self) -> Self::OutputText
fn text(&self) -> Self::OutputText
Converts the response to text format.
§Returns
Self::OutputText
- The text representation of the response.
Source§fn binary(&self) -> HttpResponseBinary
fn binary(&self) -> HttpResponseBinary
Converts the response to binary format.
§Returns
HttpResponseBinary
- The binary representation of the response.