RESTinio
Toggle main menu visibility
Loading...
Searching...
No Matches
restinio
incoming_http_msg_limits.hpp
Go to the documentation of this file.
1
/*
2
* RESTinio
3
*/
4
5
/*!
6
* @file
7
* @brief Stuff related to limits of an incoming HTTP message.
8
*
9
* @since v.0.6.12
10
*/
11
12
#
pragma
once
13
14
#
include
<
restinio
/
compiler_features
.
hpp
>
15
16
#
include
<
cstdint
>
17
#
include
<
limits
>
18
19
namespace
restinio
20
{
21
22
//
23
// incoming_http_msg_limits_t
24
//
25
/*!
26
* @brief A type of holder of limits related to an incoming HTTP message.
27
*
28
* Since v.0.6.12 RESTinio supports various limits for incoming HTTP messages.
29
* If some part of message (like the length of HTTP field name) exceeds
30
* the specified limit then that message will be ignored by RESTinio.
31
*
32
* For the compatibility with the previous versions such limits are optional.
33
* The default constructor of incoming_http_msg_limits_t sets the limits
34
* to the maximum values that cannot be exceeded.
35
*
36
* In v.0.6.12 a user has to set appropriate values for limits by his/herself.
37
* For example:
38
*
39
* @code
40
* restinio::run(
41
* restinio::on_this_thread<>()
42
* .port(8080)
43
* .address("localhost")
44
* .incoming_http_msg_limits(
45
* restinio::incoming_http_msg_limits_t{}
46
* .max_url_size(8000u)
47
* .max_field_name_size(1024u)
48
* .max_field_value_size(4096u)
49
* .max_body_size(10240u)
50
* )
51
* .request_handler(...)
52
* );
53
* @endcode
54
*
55
* @attention
56
* Setters of incoming_http_msg_limits_t doesn't checks values.
57
* It means that it is possible to set 0 as a limit for the length
58
* of field name size. That will lead to ignorance of every incoming
59
* request.
60
*
61
* @note
62
* Almost all limits except the limit for the body size are std::size_t.
63
* It means that those limits can have different borders in 32- and 64-bit
64
* mode. The limit for the body size is always std::uint64_t.
65
*
66
* @since v.0.6.12
67
*/
68
class
incoming_http_msg_limits_t
69
{
70
std::size_t
m_max_url_size
{ std::numeric_limits<std::size_t>::max() };
71
std::size_t
m_max_field_name_size
{ std::numeric_limits<std::size_t>::max() };
72
std::size_t
m_max_field_value_size
{ std::numeric_limits<std::size_t>::max() };
73
std::size_t
m_max_field_count
{ std::numeric_limits<std::size_t>::max() };
74
std::
uint64_t
m_max_body_size
{ std::numeric_limits<std::uint64_t>::max() };
75
76
public
:
77
incoming_http_msg_limits_t
()
noexcept
=
default
;
78
79
[[nodiscard]]
80
std::size_t
81
max_url_size
()
const
noexcept
{
return
m_max_url_size
; }
82
83
incoming_http_msg_limits_t
&
84
max_url_size
( std::size_t value ) &
noexcept
85
{
86
m_max_url_size
= value;
87
return
*
this
;
88
}
89
90
incoming_http_msg_limits_t
&&
91
max_url_size
( std::size_t value ) &&
noexcept
92
{
93
return
std::move(
max_url_size
(
value
)
);
94
}
95
96
[[nodiscard]]
97
std::size_t
98
max_field_name_size
()
const
noexcept
{
return
m_max_field_name_size
; }
99
100
incoming_http_msg_limits_t
&
101
max_field_name_size
( std::size_t value ) &
noexcept
102
{
103
m_max_field_name_size
= value;
104
return
*
this
;
105
}
106
107
incoming_http_msg_limits_t
&&
108
max_field_name_size
( std::size_t value ) &&
noexcept
109
{
110
return
std::move(
max_field_name_size
(
value
)
);
111
}
112
113
[[nodiscard]]
114
std::size_t
115
max_field_value_size
()
const
noexcept
{
return
m_max_field_value_size
; }
116
117
incoming_http_msg_limits_t
&
118
max_field_value_size
( std::size_t value ) &
noexcept
119
{
120
m_max_field_value_size
= value;
121
return
*
this
;
122
}
123
124
incoming_http_msg_limits_t
&&
125
max_field_value_size
( std::size_t value ) &&
noexcept
126
{
127
return
std::move(
max_field_value_size
(
value
)
);
128
}
129
130
[[nodiscard]]
131
std::size_t
132
max_field_count
()
const
noexcept
{
return
m_max_field_count
; }
133
134
incoming_http_msg_limits_t
&
135
max_field_count
( std::size_t value ) &
noexcept
136
{
137
m_max_field_count
= value;
138
return
*
this
;
139
}
140
141
incoming_http_msg_limits_t
&&
142
max_field_count
( std::size_t value ) &&
noexcept
143
{
144
return
std::move(
max_field_count
(
value
)
);
145
}
146
147
[[nodiscard]]
148
std::
uint64_t
149
max_body_size
()
const
noexcept
{
return
m_max_body_size
; }
150
151
incoming_http_msg_limits_t
&
152
max_body_size
( std::uint64_t value ) &
noexcept
153
{
154
m_max_body_size
= value;
155
return
*
this
;
156
}
157
158
incoming_http_msg_limits_t
&&
159
max_body_size
( std::uint64_t value ) &&
noexcept
160
{
161
return
std::move(
max_body_size
(
value
)
);
162
}
163
};
164
165
}
/* namespace restinio */
restinio::incoming_http_msg_limits_t
A type of holder of limits related to an incoming HTTP message.
Definition
incoming_http_msg_limits.hpp:69
restinio::incoming_http_msg_limits_t::m_max_field_value_size
std::size_t m_max_field_value_size
Definition
incoming_http_msg_limits.hpp:72
restinio::incoming_http_msg_limits_t::max_field_value_size
incoming_http_msg_limits_t & max_field_value_size(std::size_t value) &noexcept
Definition
incoming_http_msg_limits.hpp:118
restinio::incoming_http_msg_limits_t::max_body_size
incoming_http_msg_limits_t & max_body_size(std::uint64_t value) &noexcept
Definition
incoming_http_msg_limits.hpp:152
restinio::incoming_http_msg_limits_t::max_url_size
incoming_http_msg_limits_t & max_url_size(std::size_t value) &noexcept
Definition
incoming_http_msg_limits.hpp:84
restinio::incoming_http_msg_limits_t::max_field_count
incoming_http_msg_limits_t && max_field_count(std::size_t value) &&noexcept
Definition
incoming_http_msg_limits.hpp:142
restinio::incoming_http_msg_limits_t::max_url_size
incoming_http_msg_limits_t && max_url_size(std::size_t value) &&noexcept
Definition
incoming_http_msg_limits.hpp:91
restinio::incoming_http_msg_limits_t::max_field_name_size
incoming_http_msg_limits_t & max_field_name_size(std::size_t value) &noexcept
Definition
incoming_http_msg_limits.hpp:101
restinio::incoming_http_msg_limits_t::incoming_http_msg_limits_t
incoming_http_msg_limits_t() noexcept=default
restinio::incoming_http_msg_limits_t::m_max_body_size
std::uint64_t m_max_body_size
Definition
incoming_http_msg_limits.hpp:74
restinio::incoming_http_msg_limits_t::max_url_size
std::size_t max_url_size() const noexcept
Definition
incoming_http_msg_limits.hpp:81
restinio::incoming_http_msg_limits_t::max_body_size
incoming_http_msg_limits_t && max_body_size(std::uint64_t value) &&noexcept
Definition
incoming_http_msg_limits.hpp:159
restinio::incoming_http_msg_limits_t::max_field_name_size
incoming_http_msg_limits_t && max_field_name_size(std::size_t value) &&noexcept
Definition
incoming_http_msg_limits.hpp:108
restinio::incoming_http_msg_limits_t::max_field_count
std::size_t max_field_count() const noexcept
Definition
incoming_http_msg_limits.hpp:132
restinio::incoming_http_msg_limits_t::m_max_url_size
std::size_t m_max_url_size
Definition
incoming_http_msg_limits.hpp:70
restinio::incoming_http_msg_limits_t::max_field_count
incoming_http_msg_limits_t & max_field_count(std::size_t value) &noexcept
Definition
incoming_http_msg_limits.hpp:135
restinio::incoming_http_msg_limits_t::m_max_field_name_size
std::size_t m_max_field_name_size
Definition
incoming_http_msg_limits.hpp:71
restinio::incoming_http_msg_limits_t::max_field_value_size
incoming_http_msg_limits_t && max_field_value_size(std::size_t value) &&noexcept
Definition
incoming_http_msg_limits.hpp:125
restinio::incoming_http_msg_limits_t::m_max_field_count
std::size_t m_max_field_count
Definition
incoming_http_msg_limits.hpp:73
restinio::incoming_http_msg_limits_t::max_body_size
std::uint64_t max_body_size() const noexcept
Definition
incoming_http_msg_limits.hpp:149
restinio::incoming_http_msg_limits_t::max_field_name_size
std::size_t max_field_name_size() const noexcept
Definition
incoming_http_msg_limits.hpp:98
restinio::incoming_http_msg_limits_t::max_field_value_size
std::size_t max_field_value_size() const noexcept
Definition
incoming_http_msg_limits.hpp:115
restinio
Definition
sendfile_operation_default.ipp:12
Generated by
1.17.0