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