Skip to main content

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/// 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    #[set]
15    pub(super) buffer_size: usize,
16    /// Maximum size for URL path in bytes.
17    #[get(type(copy))]
18    #[set]
19    pub(super) max_path_size: usize,
20    /// Maximum number of headers allowed in a request.
21    #[get(type(copy))]
22    #[set]
23    pub(super) max_header_count: usize,
24    /// Maximum size for a header key in bytes.
25    #[get(type(copy))]
26    #[set]
27    pub(super) max_header_key_size: usize,
28    /// Maximum size for a header value in bytes.
29    #[get(type(copy))]
30    #[set]
31    pub(super) max_header_value_size: usize,
32    /// Maximum size for request body in bytes.
33    #[get(type(copy))]
34    #[set]
35    pub(super) max_body_size: usize,
36    /// Timeout for reading data in milliseconds.
37    #[get(type(copy))]
38    #[set]
39    pub(super) read_timeout_ms: u64,
40}
41
42/// HTTP request representation.
43///
44/// Contains all components of an HTTP request.
45#[derive(
46    Clone, Debug, Deserialize, DisplayDebug, Eq, Getter, GetterMut, PartialEq, Serialize, Setter,
47)]
48pub struct Request {
49    /// HTTP request method.
50    pub(super) method: RequestMethod,
51    /// Request host.
52    pub(super) host: RequestHost,
53    /// HTTP protocol version.
54    pub(super) version: RequestVersion,
55    /// Request path.
56    pub(super) path: RequestPath,
57    /// URL query parameters.
58    pub(super) querys: RequestQuerys,
59    /// HTTP headers collection.
60    pub(super) headers: RequestHeaders,
61    /// Request body content.
62    pub(super) body: RequestBody,
63}
64
65/// HTTP request representation.
66#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, New, PartialEq, Serialize)]
67pub(crate) struct Http;
68
69/// WebSocket request representation.
70#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, New, PartialEq, Serialize)]
71pub(crate) struct Ws;