Skip to content

Commit 6a038f1

Browse files
authored
Standardize HTTP headers to Title Case
This PR updates all HTTP headers to use Title Case formatting, aligning with RFC 7231 recommendations and ensuring consistency across responses. This change improves readability and aligns our implementation with industry standards. No functional changes were introduced. Only header formatting has been adjusted.
1 parent 42d2aad commit 6a038f1

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

src/literals.h

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,56 @@ namespace asyncsrv {
77

88
static constexpr const char *empty = "";
99

10-
static constexpr const char *T_inline = "inline";
11-
static constexpr const char *T_attachment = "attachment; filename=\"%s\"";
12-
1310
static constexpr const char *T__opaque = "\", opaque=\"";
1411
static constexpr const char *T_100_CONTINUE = "100-continue";
1512
static constexpr const char *T_13 = "13";
16-
static constexpr const char *T_ACCEPT = "accept";
17-
static constexpr const char *T_Accept_Ranges = "accept-ranges";
18-
static constexpr const char *T_app_xform_urlencoded = "application/x-www-form-urlencoded";
19-
static constexpr const char *T_AUTH = "authorization";
13+
static constexpr const char *T_ACCEPT = "Accept";
14+
static constexpr const char *T_Accept_Ranges = "Accept-Ranges";
15+
static constexpr const char *T_attachment = "attachment; filename=\"%s\"";
16+
static constexpr const char *T_AUTH = "Authorization";
2017
static constexpr const char *T_auth_nonce = "\", qop=\"auth\", nonce=\"";
21-
static constexpr const char *T_BASIC = "basic";
22-
static constexpr const char *T_BASIC_REALM = "basic realm=\"";
23-
static constexpr const char *T_BEARER = "bearer";
18+
static constexpr const char *T_BASIC = "Basic";
19+
static constexpr const char *T_BASIC_REALM = "Basic realm=\"";
20+
static constexpr const char *T_BEARER = "Bearer";
2421
static constexpr const char *T_BODY = "body";
25-
static constexpr const char *T_Cache_Control = "cache-control";
22+
static constexpr const char *T_Cache_Control = "Cache-Control";
2623
static constexpr const char *T_chunked = "chunked";
2724
static constexpr const char *T_close = "close";
2825
static constexpr const char *T_cnonce = "cnonce";
29-
static constexpr const char *T_Connection = "connection";
30-
static constexpr const char *T_Content_Disposition = "content-disposition";
31-
static constexpr const char *T_Content_Encoding = "content-encoding";
32-
static constexpr const char *T_Content_Length = "content-length";
33-
static constexpr const char *T_Content_Type = "content-type";
34-
static constexpr const char *T_Content_Location = "content-location";
35-
static constexpr const char *T_Cookie = "cookie";
36-
static constexpr const char *T_CORS_ACAC = "access-control-allow-credentials";
37-
static constexpr const char *T_CORS_ACAH = "access-control-allow-headers";
38-
static constexpr const char *T_CORS_ACAM = "access-control-allow-methods";
39-
static constexpr const char *T_CORS_ACAO = "access-control-allow-origin";
40-
static constexpr const char *T_CORS_ACMA = "access-control-max-age";
41-
static constexpr const char *T_CORS_O = "origin";
26+
static constexpr const char *T_Connection = "Connection";
27+
static constexpr const char *T_Content_Disposition = "Content-Disposition";
28+
static constexpr const char *T_Content_Encoding = "Content-Encoding";
29+
static constexpr const char *T_Content_Length = "Content-Length";
30+
static constexpr const char *T_Content_Type = "Content-Type";
31+
static constexpr const char *T_Content_Location = "Content-Location";
32+
static constexpr const char *T_Cookie = "Cookie";
33+
static constexpr const char *T_CORS_ACAC = "Access-Control-Allow-Credentials";
34+
static constexpr const char *T_CORS_ACAH = "Access-Control-Allow-Headers";
35+
static constexpr const char *T_CORS_ACAM = "Access-Control-Allow-Methods";
36+
static constexpr const char *T_CORS_ACAO = "Access-Control-Allow-Origin";
37+
static constexpr const char *T_CORS_ACMA = "Access-Control-Max-Age";
38+
static constexpr const char *T_CORS_O = "Origin";
4239
static constexpr const char *T_data_ = "data: ";
43-
static constexpr const char *T_Date = "date";
44-
static constexpr const char *T_DIGEST = "digest";
45-
static constexpr const char *T_DIGEST_ = "digest ";
46-
static constexpr const char *T_ETag = "etag";
40+
static constexpr const char *T_Date = "Date";
41+
static constexpr const char *T_DIGEST = "Digest";
42+
static constexpr const char *T_DIGEST_ = "Digest ";
43+
static constexpr const char *T_ETag = "ETag";
4744
static constexpr const char *T_event_ = "event: ";
48-
static constexpr const char *T_EXPECT = "expect";
45+
static constexpr const char *T_EXPECT = "Expect";
4946
static constexpr const char *T_FALSE = "false";
5047
static constexpr const char *T_filename = "filename";
5148
static constexpr const char *T_gzip = "gzip";
5249
static constexpr const char *T_Host = "host";
5350
static constexpr const char *T_HTTP_1_0 = "HTTP/1.0";
5451
static constexpr const char *T_HTTP_100_CONT = "HTTP/1.1 100 Continue\r\n\r\n";
5552
static constexpr const char *T_id__ = "id: ";
56-
static constexpr const char *T_IMS = "if-modified-since";
57-
static constexpr const char *T_INM = "if-none-match";
53+
static constexpr const char *T_IMS = "If-Modified-Since";
54+
static constexpr const char *T_INM = "If-None-Match";
55+
static constexpr const char *T_inline = "inline";
5856
static constexpr const char *T_keep_alive = "keep-alive";
59-
static constexpr const char *T_Last_Event_ID = "last-event-id";
60-
static constexpr const char *T_Last_Modified = "last-modified";
61-
static constexpr const char *T_LOCATION = "location";
57+
static constexpr const char *T_Last_Event_ID = "Last-Event-ID";
58+
static constexpr const char *T_Last_Modified = "Last-Modified";
59+
static constexpr const char *T_LOCATION = "Location";
6260
static constexpr const char *T_LOGIN_REQ = "Login Required";
6361
static constexpr const char *T_MULTIPART_ = "multipart/";
6462
static constexpr const char *T_name = "name";
@@ -72,21 +70,20 @@ static constexpr const char *T_realm = "realm";
7270
static constexpr const char *T_realm__ = "realm=\"";
7371
static constexpr const char *T_response = "response";
7472
static constexpr const char *T_retry_ = "retry: ";
75-
static constexpr const char *T_retry_after = "retry-after";
73+
static constexpr const char *T_retry_after = "Retry-After";
7674
static constexpr const char *T_nn = "\n\n";
7775
static constexpr const char *T_rn = "\r\n";
7876
static constexpr const char *T_rnrn = "\r\n\r\n";
79-
static constexpr const char *T_Server = "server";
80-
static constexpr const char *T_Transfer_Encoding = "transfer-encoding";
77+
static constexpr const char *T_Server = "Server";
78+
static constexpr const char *T_Transfer_Encoding = "Transfer-Encoding";
8179
static constexpr const char *T_TRUE = "true";
82-
static constexpr const char *T_UPGRADE = "upgrade";
80+
static constexpr const char *T_UPGRADE = "Upgrade";
8381
static constexpr const char *T_uri = "uri";
8482
static constexpr const char *T_username = "username";
8583
static constexpr const char *T_WS = "websocket";
86-
static constexpr const char *T_WWW_AUTH = "www-authenticate";
84+
static constexpr const char *T_WWW_AUTH = "WWW-Authenticate";
8785

8886
// HTTP Methods
89-
9087
static constexpr const char *T_ANY = "ANY";
9188
static constexpr const char *T_GET = "GET";
9289
static constexpr const char *T_POST = "POST";
@@ -129,6 +126,7 @@ static constexpr const char *T_application_json = "application/json";
129126
static constexpr const char *T_application_msgpack = "application/msgpack";
130127
static constexpr const char *T_application_pdf = "application/pdf";
131128
static constexpr const char *T_application_x_gzip = "application/x-gzip";
129+
static constexpr const char *T_app_xform_urlencoded = "application/x-www-form-urlencoded";
132130
static constexpr const char *T_application_zip = "application/zip";
133131
static constexpr const char *T_font_eot = "font/eot";
134132
static constexpr const char *T_font_ttf = "font/ttf";
@@ -178,19 +176,22 @@ static constexpr const char *T_HTTP_CODE_412 = "Precondition Failed";
178176
static constexpr const char *T_HTTP_CODE_413 = "Request Entity Too Large";
179177
static constexpr const char *T_HTTP_CODE_414 = "Request-URI Too Large";
180178
static constexpr const char *T_HTTP_CODE_415 = "Unsupported Media Type";
181-
static constexpr const char *T_HTTP_CODE_416 = "Requested range not satisfiable";
179+
static constexpr const char *T_HTTP_CODE_416 = "Requested Range Not Satisfiable";
182180
static constexpr const char *T_HTTP_CODE_417 = "Expectation Failed";
183181
static constexpr const char *T_HTTP_CODE_429 = "Too Many Requests";
184182
static constexpr const char *T_HTTP_CODE_500 = "Internal Server Error";
185183
static constexpr const char *T_HTTP_CODE_501 = "Not Implemented";
186184
static constexpr const char *T_HTTP_CODE_502 = "Bad Gateway";
187185
static constexpr const char *T_HTTP_CODE_503 = "Service Unavailable";
188186
static constexpr const char *T_HTTP_CODE_504 = "Gateway Time-out";
189-
static constexpr const char *T_HTTP_CODE_505 = "HTTP Version not supported";
187+
static constexpr const char *T_HTTP_CODE_505 = "HTTP Version Not Supported";
190188
static constexpr const char *T_HTTP_CODE_ANY = "Unknown code";
191189

192-
static constexpr const uint8_t T_only_once_headers_len = 11;
193-
static constexpr const char *T_only_once_headers[] = {T_Content_Length, T_Content_Type, T_Date, T_ETag, T_Last_Modified, T_LOCATION, T_retry_after,
194-
T_Transfer_Encoding, T_Content_Location, T_Server, T_WWW_AUTH};
190+
static constexpr const char *T_only_once_headers[] = {
191+
T_Accept_Ranges, T_Content_Length, T_Content_Type, T_Connection, T_CORS_ACAC, T_CORS_ACAH, T_CORS_ACAM, T_CORS_ACAO,
192+
T_CORS_ACMA, T_CORS_O, T_Date, T_DIGEST, T_ETag, T_Last_Modified, T_LOCATION, T_retry_after,
193+
T_Transfer_Encoding, T_Content_Location, T_Server, T_WWW_AUTH
194+
};
195+
static constexpr size_t T_only_once_headers_len = sizeof(T_only_once_headers) / sizeof(T_only_once_headers[0]);
195196

196197
} // namespace asyncsrv

0 commit comments

Comments
 (0)