Skip to content

Commit

Permalink
Add UWS_HTTP_MAX_HEADERS_COUNT, raise default
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB authored and Alex Hultman committed Dec 18, 2023
1 parent d948b51 commit 85c6f0f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/HttpParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 85c6f0f

Please sign in to comment.