diff --git a/src/HttpParser.h b/src/HttpParser.h index 797be36..a95dba0 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -41,6 +41,14 @@ namespace uWS { static const unsigned int MINIMUM_HTTP_POST_PADDING = 32; static void *FULLPTR = (void *)~(uintptr_t)0; +/* STL needs one of these */ +template +std::optional optional_ptr(T *ptr) { + return ptr ? std::optional(ptr) : std::nullopt; +} + +static const size_t MAX_FALLBACK_SIZE = (size_t) atoi(optional_ptr(getenv("UWS_HTTP_MAX_HEADERS_SIZE")).value_or((char *) "4096")); + struct HttpRequest { friend struct HttpParser; @@ -172,8 +180,6 @@ private: /* This guy really has only 30 bits since we reserve two highest bits to chunked encoding parsing state */ unsigned int remainingStreamingBytes = 0; - const size_t MAX_FALLBACK_SIZE = 1024 * 4; - /* Returns UINT_MAX on error. Maximum 999999999 is allowed. */ static unsigned int toUnsignedInteger(std::string_view str) { /* We assume at least 32-bit integer giving us safely 999999999 (9 number of 9s) */