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 RequestConfig {
22    /// Buffer size for reading operations.
23    #[get(copy)]
24    pub(super) buffer_size: usize,
25    /// Maximum length for HTTP request line in bytes.
26    #[get(copy)]
27    pub(super) max_request_line_length: usize,
28    /// Maximum length for URL path in bytes.
29    #[get(copy)]
30    pub(super) max_path_length: usize,
31    /// Maximum length for query string in bytes.
32    #[get(copy)]
33    pub(super) max_query_length: usize,
34    /// Maximum length for a single header line in bytes.
35    #[get(copy)]
36    pub(super) max_header_line_length: usize,
37    /// Maximum number of headers allowed in a request.
38    #[get(copy)]
39    pub(super) max_header_count: usize,
40    /// Maximum length for a header key in bytes.
41    #[get(copy)]
42    pub(super) max_header_key_length: usize,
43    /// Maximum length for a header value in bytes.
44    #[get(copy)]
45    pub(super) max_header_value_length: usize,
46    /// Maximum size for request body in bytes.
47    #[get(copy)]
48    pub(super) max_body_size: usize,
49    /// Maximum size for WebSocket frame in bytes.
50    #[get(copy)]
51    pub(super) max_ws_frame_size: usize,
52    /// Maximum number of WebSocket frames to process in a single request.
53    #[get(copy)]
54    pub(super) max_ws_frames: usize,
55    /// Timeout for reading HTTP request in milliseconds.
56    #[get(copy)]
57    pub(super) http_read_timeout_ms: u64,
58    /// Timeout for reading WebSocket frames in milliseconds.
59    #[get(copy)]
60    pub(super) ws_read_timeout_ms: u64,
61}
62
63/// HTTP request representation.
64///
65/// Contains all components of an HTTP request.
66#[derive(Debug, Clone, PartialEq, Eq, Getter, DisplayDebug)]
67pub struct Request {
68    /// HTTP request method.
69    pub(super) method: RequestMethod,
70    /// Request host.
71    pub(super) host: RequestHost,
72    /// HTTP protocol version.
73    pub(super) version: RequestVersion,
74    /// Request path.
75    pub(super) path: RequestPath,
76    /// URL query parameters.
77    pub(super) querys: RequestQuerys,
78    /// HTTP headers collection.
79    pub(super) headers: RequestHeaders,
80    /// Request body content.
81    pub(super) body: RequestBody,
82}