http_request/response/type.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
use std::collections::HashMap;
/// 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`: A `HashMap<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`: A `Vec<u8>` representing the body of the HTTP response, which contains the content being returned.
#[derive(Debug, Clone, PartialEq)]
pub struct HttpResponse {
/// The HTTP version of the response (e.g., "HTTP/1.1").
pub http_version: String,
/// The HTTP status code (e.g., 200, 404).
pub status_code: u16,
/// The status text associated with the status code (e.g., "OK", "Not Found").
pub status_text: String,
/// A `HashMap` of headers, where the key is the header name and the value is the header value.
pub headers: HashMap<String, String>,
/// The body of the response, which contains the content being returned.
pub body: Vec<u8>,
}
/// 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`: A `HashMap<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`: A `Vec<u8>` representing the body of the HTTP response, which contains the content being returned.
#[derive(Debug, Clone, PartialEq)]
pub struct HttpResponseText {
/// The HTTP version of the response (e.g., "HTTP/1.1").
pub http_version: String,
/// The HTTP status code (e.g., 200, 404).
pub status_code: u16,
/// The status text associated with the status code (e.g., "OK", "Not Found").
pub status_text: String,
/// A `HashMap` of headers, where the key is the header name and the value is the header value.
pub headers: HashMap<String, String>,
/// The body of the response, which contains the content being returned.
pub body: String,
}