From 85c6f0fb69dd234e68bad01a81a914ecf95cb59b Mon Sep 17 00:00:00 2001 From: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:15:24 +0100 Subject: [PATCH] Add UWS_HTTP_MAX_HEADERS_COUNT, raise default --- src/HttpParser.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/HttpParser.h b/src/HttpParser.h index a95dba094..5ff6cbda0 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -48,16 +48,18 @@ std::optional<T *> optional_ptr(T *ptr) { } static const size_t MAX_FALLBACK_SIZE = (size_t) atoi(optional_ptr(getenv("UWS_HTTP_MAX_HEADERS_SIZE")).value_or((char *) "4096")); +#ifndef UWS_HTTP_MAX_HEADERS_COUNT +#define UWS_HTTP_MAX_HEADERS_COUNT 100 +#endif struct HttpRequest { friend struct HttpParser; private: - const static int MAX_HEADERS = 50; struct Header { std::string_view key, value; - } headers[MAX_HEADERS]; + } headers[UWS_HTTP_MAX_HEADERS_COUNT]; bool ancientHttp; unsigned int querySeparator; bool didYield; @@ -327,7 +329,7 @@ struct HttpParser { } headers++; - for (unsigned int i = 1; i < HttpRequest::MAX_HEADERS - 1; i++) { + for (unsigned int i = 1; i < UWS_HTTP_MAX_HEADERS_COUNT - 1; i++) { /* Lower case and consume the field name */ preliminaryKey = postPaddedBuffer; postPaddedBuffer = (char *) consumeFieldName(postPaddedBuffer);