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