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