http_type/response/
type.rs

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