http_type/response/
type.rs

1use super::error::Error as ResponseError;
2use crate::*;
3
4///  Response data
5pub type ResponseData = Vec<u8>;
6
7///  Response body
8pub type ResponseBody = Vec<u8>;
9
10/// Response version
11pub type ResponseVersion = String;
12
13/// Response status code
14pub type ResponseStatusCode = usize;
15
16/// Response reason phrase
17pub type ResponseReasonPhrase = String;
18
19///  Response result
20pub type ResponseResult = Result<(), ResponseError>;
21
22///  Close stream result
23pub type CloseStreamResult = Result<(), ResponseError>;
24
25/// Represents an HTTP response.
26///
27/// # Fields
28/// - `version`: The HTTP version of the response (e.g., HTTP/1.1).
29/// - `status_code`: The status code of the response (e.g., 200, 404).
30/// - `reason_phrase`: The reason phrase corresponding to the status code (e.g., OK, Not Found).
31/// - `headers`: A collection of HTTP headers as key-value pairs.
32/// - `body`: The binary body of the response.
33/// - `response`: The serialized HTTP response including headers and body.
34#[derive(Debug, Clone, Lombok, PartialEq, Eq)]
35pub struct Response {
36    #[set(skip)]
37    pub(super) version: ResponseVersion,
38    pub(super) status_code: ResponseStatusCode,
39    #[set(skip)]
40    pub(super) reason_phrase: ResponseReasonPhrase,
41    pub(super) headers: HashMap<String, String>,
42    #[set(skip)]
43    pub(super) body: ResponseBody,
44    #[set(super)]
45    pub(super) response: ResponseData,
46}