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///  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: ResponseHeaders,
42    #[set(skip)]
43    pub(super) body: ResponseBody,
44    #[set(super)]
45    pub(super) response: ResponseData,
46}