Skip to main content

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 are crate-internal (§17.18): a consumer reaches them through
12/// the generated `get_*` and `set_*` accessors.
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(crate) buffer_size: usize,
18    /// Maximum size for URL path in bytes.
19    #[get(type(copy))]
20    pub(crate) max_path_size: usize,
21    /// Maximum number of headers allowed in a request.
22    #[get(type(copy))]
23    pub(crate) max_header_count: usize,
24    /// Maximum size for a header key in bytes.
25    #[get(type(copy))]
26    pub(crate) max_header_key_size: usize,
27    /// Maximum size for a header value in bytes.
28    #[get(type(copy))]
29    pub(crate) max_header_value_size: usize,
30    /// Maximum size for request body in bytes.
31    #[get(type(copy))]
32    pub(crate) max_body_size: usize,
33    /// Timeout for reading data in milliseconds.
34    #[get(type(copy))]
35    pub(crate) read_timeout_ms: u64,
36}
37
38/// HTTP request representation.
39///
40/// Contains all components of an HTTP request.
41///
42/// The fields are crate-internal (§17.18): a consumer reaches them through
43/// the generated `get_*` and `set_*` accessors.
44#[derive(Clone, Data, Debug, Deserialize, DisplayDebug, Eq, PartialEq, Serialize)]
45pub struct Request {
46    /// HTTP request method.
47    pub(crate) method: Method,
48    /// Request host.
49    pub(crate) host: String,
50    /// HTTP protocol version.
51    pub(crate) version: HttpVersion,
52    /// Request path.
53    pub(crate) path: String,
54    /// URL query parameters.
55    pub(crate) querys: RequestQuerys,
56    /// HTTP headers collection.
57    pub(crate) headers: RequestHeaders,
58    /// Request body content.
59    pub(crate) body: Vec<u8>,
60}