http_type/request/struct.rs
1use super::*;
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/// Since all fields implement `Copy`, this struct is lightweight
9/// and can be easily cloned and shared.
10#[derive(Clone, Copy, Data, Debug, Deserialize, DisplayDebug, Eq, New, PartialEq, Serialize)]
11pub struct RequestConfig {
12 /// Buffer size for reading operations.
13 #[get(type(copy))]
14 pub buffer_size: usize,
15 /// Maximum size for URL path in bytes.
16 #[get(type(copy))]
17 pub max_path_size: usize,
18 /// Maximum number of headers allowed in a request.
19 #[get(type(copy))]
20 pub max_header_count: usize,
21 /// Maximum size for a header key in bytes.
22 #[get(type(copy))]
23 pub max_header_key_size: usize,
24 /// Maximum size for a header value in bytes.
25 #[get(type(copy))]
26 pub max_header_value_size: usize,
27 /// Maximum size for request body in bytes.
28 #[get(type(copy))]
29 pub max_body_size: usize,
30 /// Timeout for reading data in milliseconds.
31 #[get(type(copy))]
32 pub read_timeout_ms: u64,
33}
34
35/// HTTP request representation.
36///
37/// Contains all components of an HTTP request.
38#[derive(
39 Clone, Debug, Deserialize, DisplayDebug, Eq, Getter, GetterMut, PartialEq, Serialize, Setter,
40)]
41pub struct Request {
42 /// HTTP request method.
43 pub method: RequestMethod,
44 /// Request host.
45 pub host: RequestHost,
46 /// HTTP protocol version.
47 pub version: RequestVersion,
48 /// Request path.
49 pub path: RequestPath,
50 /// URL query parameters.
51 pub querys: RequestQuerys,
52 /// HTTP headers collection.
53 pub headers: RequestHeaders,
54 /// Request body content.
55 pub body: RequestBody,
56}