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///
11/// The fields stay `pub`: `type/tests/request` reads them directly, so this is
12/// published API and §17.14 does not recall it (semver).
13#[derive(Clone, Copy, Data, Debug, Deserialize, DisplayDebug, Eq, New, PartialEq, Serialize)]
14pub struct RequestConfig {
15 /// Buffer size for reading operations.
16 #[get(type(copy))]
17 pub buffer_size: usize,
18 /// Maximum size for URL path in bytes.
19 #[get(type(copy))]
20 pub max_path_size: usize,
21 /// Maximum number of headers allowed in a request.
22 #[get(type(copy))]
23 pub max_header_count: usize,
24 /// Maximum size for a header key in bytes.
25 #[get(type(copy))]
26 pub max_header_key_size: usize,
27 /// Maximum size for a header value in bytes.
28 #[get(type(copy))]
29 pub max_header_value_size: usize,
30 /// Maximum size for request body in bytes.
31 #[get(type(copy))]
32 pub max_body_size: usize,
33 /// Timeout for reading data in milliseconds.
34 #[get(type(copy))]
35 pub read_timeout_ms: u64,
36}
37
38/// HTTP request representation.
39///
40/// Contains all components of an HTTP request.
41///
42/// The fields stay `pub`: `type/tests/request` builds fixtures through them, so
43/// this is published API and §17.14 does not recall it (semver).
44#[derive(Clone, Data, Debug, Deserialize, DisplayDebug, Eq, PartialEq, Serialize)]
45pub struct Request {
46 /// HTTP request method.
47 pub method: RequestMethod,
48 /// Request host.
49 pub host: RequestHost,
50 /// HTTP protocol version.
51 pub version: RequestVersion,
52 /// Request path.
53 pub path: RequestPath,
54 /// URL query parameters.
55 pub querys: RequestQuerys,
56 /// HTTP headers collection.
57 pub headers: RequestHeaders,
58 /// Request body content.
59 pub body: RequestBody,
60}