Skip to content

Commit 0efda47

Browse files
uNetworkingABAlex Hultman
authored andcommitted
Add UWS_HTTP_MAX_HEADERS_SIZE config
1 parent b2ea51b commit 0efda47

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/HttpParser.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ namespace uWS {
4141
static const unsigned int MINIMUM_HTTP_POST_PADDING = 32;
4242
static void *FULLPTR = (void *)~(uintptr_t)0;
4343

44+
/* STL needs one of these */
45+
template <typename T>
46+
std::optional<T *> optional_ptr(T *ptr) {
47+
return ptr ? std::optional<T *>(ptr) : std::nullopt;
48+
}
49+
50+
static const size_t MAX_FALLBACK_SIZE = (size_t) atoi(optional_ptr(getenv("UWS_HTTP_MAX_HEADERS_SIZE")).value_or((char *) "4096"));
51+
4452
struct HttpRequest {
4553

4654
friend struct HttpParser;
@@ -172,8 +180,6 @@ struct HttpParser {
172180
/* This guy really has only 30 bits since we reserve two highest bits to chunked encoding parsing state */
173181
unsigned int remainingStreamingBytes = 0;
174182

175-
const size_t MAX_FALLBACK_SIZE = 1024 * 4;
176-
177183
/* Returns UINT_MAX on error. Maximum 999999999 is allowed. */
178184
static unsigned int toUnsignedInteger(std::string_view str) {
179185
/* We assume at least 32-bit integer giving us safely 999999999 (9 number of 9s) */

0 commit comments

Comments
 (0)