http_type/request/
struct.rs

1use crate::*;
2
3/// Configuration for HTTP request parsing security limits.
4///
5/// This struct defines various limits and constraints to prevent
6/// denial-of-service attacks and other security vulnerabilities
7/// when parsing HTTP requests.
8#[derive(
9    Debug,
10    Clone,
11    Copy,
12    PartialEq,
13    Eq,
14    Getter,
15    GetterMut,
16    Setter,
17    DisplayDebug,
18    Deserialize,
19    Serialize,
20)]
21pub struct RequestConfigData {
22    /// Buffer size for reading operations.
23    #[get(type(copy))]
24    pub(super) buffer_size: usize,
25    /// Maximum length for HTTP request line in bytes.
26    #[get(type(copy))]
27    pub(super) max_request_line_length: usize,
28    /// Maximum length for URL path in bytes.
29    #[get(type(copy))]
30    pub(super) max_path_length: usize,
31    /// Maximum length for query string in bytes.
32    #[get(type(copy))]
33    pub(super) max_query_length: usize,
34    /// Maximum length for a single header line in bytes.
35    #[get(type(copy))]
36    pub(super) max_header_line_length: usize,
37    /// Maximum number of headers allowed in a request.
38    #[get(type(copy))]
39    pub(super) max_header_count: usize,
40    /// Maximum length for a header key in bytes.
41    #[get(type(copy))]
42    pub(super) max_header_key_length: usize,
43    /// Maximum length for a header value in bytes.
44    #[get(type(copy))]
45    pub(super) max_header_value_length: usize,
46    /// Maximum size for request body in bytes.
47    #[get(type(copy))]
48    pub(super) max_body_size: usize,
49    /// Maximum size for WebSocket frame in bytes.
50    #[get(type(copy))]
51    pub(super) max_ws_frame_size: usize,
52    /// Maximum number of WebSocket frames to process in a single request.
53    #[get(type(copy))]
54    pub(super) max_ws_frames: usize,
55    /// Timeout for reading HTTP request in milliseconds.
56    #[get(type(copy))]
57    pub(super) http_read_timeout_ms: u64,
58    /// Timeout for reading WebSocket frames in milliseconds.
59    #[get(type(copy))]
60    pub(super) ws_read_timeout_ms: u64,
61}
62
63/// Thread-safe configuration wrapper for HTTP request parsing.
64///
65/// This struct uses `ArcRwLock` to provide thread-safe access to `RequestConfigData `,
66/// allowing concurrent reads and exclusive writes. It is the public-facing API
67/// for configuring HTTP request parsing limits.
68#[derive(Clone, Getter, CustomDebug, DisplayDebug)]
69pub struct RequestConfig(#[get(pub(super))] pub(super) ArcRwLock<RequestConfigData>);
70
71/// HTTP request representation.
72///
73/// Contains all components of an HTTP request.
74#[derive(Debug, Clone, Eq, PartialEq, Getter, DisplayDebug)]
75pub struct Request {
76    /// HTTP request method.
77    pub(super) method: RequestMethod,
78    /// Request host.
79    pub(super) host: RequestHost,
80    /// HTTP protocol version.
81    pub(super) version: RequestVersion,
82    /// Request path.
83    pub(super) path: RequestPath,
84    /// URL query parameters.
85    pub(super) querys: RequestQuerys,
86    /// HTTP headers collection.
87    pub(super) headers: RequestHeaders,
88    /// Request body content.
89    pub(super) body: RequestBody,
90}