Skip to content

Commit ef78dfd

Browse files
authored
Switch error message strings to constexpr (#1925)
This changes their linkage so that files which include this header will avoid having unnecessary static global constructors.
1 parent 8dd7fcb commit ef78dfd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/HttpErrors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum HttpError {
3131
#ifndef UWS_HTTPRESPONSE_NO_WRITEMARK
3232

3333
/* Returned parser errors match this LUT. */
34-
static const std::string_view httpErrorResponses[] = {
34+
static constexpr std::string_view httpErrorResponses[] = {
3535
"", /* Zeroth place is no error so don't use it */
3636
"HTTP/1.1 505 HTTP Version Not Supported\r\nConnection: close\r\n\r\n<h1>HTTP Version Not Supported</h1><p>This server does not support HTTP/1.0.</p><hr><i>uWebSockets/20 Server</i>",
3737
"HTTP/1.1 431 Request Header Fields Too Large\r\nConnection: close\r\n\r\n<h1>Request Header Fields Too Large</h1><hr><i>uWebSockets/20 Server</i>",
@@ -40,7 +40,7 @@ static const std::string_view httpErrorResponses[] = {
4040

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

0 commit comments

Comments
 (0)