From e50410a03c7ae62647fd0c09760e74cdb4ac84d3 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Wed, 13 May 2026 13:43:19 -0700 Subject: [PATCH] Switch error message strings to constexpr This changes their linkage so that files which include this header will avoid having unnecessary static global constructors. --- src/HttpErrors.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HttpErrors.h b/src/HttpErrors.h index a17a1c737..28a1354a4 100644 --- a/src/HttpErrors.h +++ b/src/HttpErrors.h @@ -31,7 +31,7 @@ enum HttpError { #ifndef UWS_HTTPRESPONSE_NO_WRITEMARK /* Returned parser errors match this LUT. */ -static const std::string_view httpErrorResponses[] = { +static constexpr std::string_view httpErrorResponses[] = { "", /* Zeroth place is no error so don't use it */ "HTTP/1.1 505 HTTP Version Not Supported\r\nConnection: close\r\n\r\n

HTTP Version Not Supported

This server does not support HTTP/1.0.


uWebSockets/20 Server", "HTTP/1.1 431 Request Header Fields Too Large\r\nConnection: close\r\n\r\n

Request Header Fields Too Large


uWebSockets/20 Server", @@ -40,7 +40,7 @@ static const std::string_view httpErrorResponses[] = { #else /* Anonymized pages */ -static const std::string_view httpErrorResponses[] = { +static constexpr std::string_view httpErrorResponses[] = { "", /* Zeroth place is no error so don't use it */ "HTTP/1.1 505 HTTP Version Not Supported\r\nConnection: close\r\n\r\n", "HTTP/1.1 431 Request Header Fields Too Large\r\nConnection: close\r\n\r\n",