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(Debug, Clone, Copy, PartialEq, Eq, Data, DisplayDebug, Deserialize, Serialize)]
9pub struct RequestConfig {
10 /// Buffer size for reading operations.
11 pub(super) buffer_size: usize,
12 /// Maximum length for HTTP request line in bytes.
13 #[new(skip)]
14 pub(super) max_request_line_length: usize,
15 /// Maximum length for URL path in bytes.
16 #[new(skip)]
17 pub(super) max_path_length: usize,
18 /// Maximum length for query string in bytes.
19 #[new(skip)]
20 pub(super) max_query_length: usize,
21 /// Maximum length for a single header line in bytes.
22 #[new(skip)]
23 pub(super) max_header_line_length: usize,
24 /// Maximum number of headers allowed in a request.
25 #[new(skip)]
26 pub(super) max_header_count: usize,
27 /// Maximum length for a header key in bytes.
28 #[new(skip)]
29 pub(super) max_header_key_length: usize,
30 /// Maximum length for a header value in bytes.
31 #[new(skip)]
32 pub(super) max_header_value_length: usize,
33 /// Maximum size for request body in bytes.
34 pub(super) max_body_size: usize,
35 /// Maximum size for WebSocket frame in bytes.
36 #[new(skip)]
37 pub(super) max_ws_frame_size: usize,
38 /// Maximum number of WebSocket frames to process in a single request.
39 #[new(skip)]
40 pub(super) max_ws_frames: usize,
41 /// Timeout for reading HTTP request in milliseconds.
42 pub(super) http_read_timeout_ms: u64,
43 /// Timeout for reading WebSocket frames in milliseconds.
44 pub(super) ws_read_timeout_ms: u64,
45}
46
47/// HTTP request representation.
48///
49/// Contains all components of an HTTP request.
50#[derive(Debug, Clone, PartialEq, Eq, Getter, DisplayDebug, New)]
51pub struct Request {
52 /// HTTP request method.
53 pub(super) method: RequestMethod,
54 /// Request host.
55 pub(super) host: RequestHost,
56 /// HTTP protocol version.
57 pub(super) version: RequestVersion,
58 /// Request path.
59 pub(super) path: RequestPath,
60 /// URL query parameters.
61 pub(super) querys: RequestQuerys,
62 /// HTTP headers collection.
63 pub(super) headers: RequestHeaders,
64 /// Request body content.
65 pub(super) body: RequestBody,
66}