Skip to content

Commit ef91101

Browse files
Merge branch 'main' into fix/mp4-content-type-header
2 parents d6b43f4 + 0a48baf commit ef91101

File tree

2 files changed

+54
-45
lines changed

2 files changed

+54
-45
lines changed

src/WebResponses.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,10 @@ void AsyncFileResponse::_setContentTypeFromPath(const String &path) {
662662
_contentType = T_image_svg_xml;
663663
} else if (strcmp(dot, T__jpg) == 0) {
664664
_contentType = T_image_jpeg;
665+
} else if (strcmp(dot, T__webp) == 0) {
666+
_contentType = T_image_webp;
667+
} else if (strcmp(dot, T__avif) == 0) {
668+
_contentType = T_image_avif;
665669
} else if (strcmp(dot, T__gif) == 0) {
666670
_contentType = T_image_gif;
667671
} else if (strcmp(dot, T__woff2) == 0) {

src/literals.h

Lines changed: 50 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";
@@ -106,6 +103,7 @@ static constexpr const char *T_RCT_EVENT = "RCT_EVENT";
106103
static constexpr const char *T_ERROR = "ERROR";
107104

108105
// extensions & MIME-Types
106+
static constexpr const char *T__avif = ".avif";
109107
static constexpr const char *T__css = ".css";
110108
static constexpr const char *T__eot = ".eot";
111109
static constexpr const char *T__gif = ".gif";
@@ -121,6 +119,7 @@ static constexpr const char *T__pdf = ".pdf";
121119
static constexpr const char *T__png = ".png";
122120
static constexpr const char *T__svg = ".svg";
123121
static constexpr const char *T__ttf = ".ttf";
122+
static constexpr const char *T__webp = ".webp";
124123
static constexpr const char *T__woff = ".woff";
125124
static constexpr const char *T__woff2 = ".woff2";
126125
static constexpr const char *T__xml = ".xml";
@@ -130,15 +129,18 @@ static constexpr const char *T_application_json = "application/json";
130129
static constexpr const char *T_application_msgpack = "application/msgpack";
131130
static constexpr const char *T_application_pdf = "application/pdf";
132131
static constexpr const char *T_application_x_gzip = "application/x-gzip";
132+
static constexpr const char *T_app_xform_urlencoded = "application/x-www-form-urlencoded";
133133
static constexpr const char *T_application_zip = "application/zip";
134134
static constexpr const char *T_font_eot = "font/eot";
135135
static constexpr const char *T_font_ttf = "font/ttf";
136136
static constexpr const char *T_font_woff = "font/woff";
137137
static constexpr const char *T_font_woff2 = "font/woff2";
138+
static constexpr const char *T_image_avif = "image/avif";
138139
static constexpr const char *T_image_gif = "image/gif";
139140
static constexpr const char *T_image_jpeg = "image/jpeg";
140141
static constexpr const char *T_image_png = "image/png";
141142
static constexpr const char *T_image_svg_xml = "image/svg+xml";
143+
static constexpr const char *T_image_webp = "image/webp";
142144
static constexpr const char *T_image_x_icon = "image/x-icon";
143145
static constexpr const char *T_text_css = "text/css";
144146
static constexpr const char *T_text_event_stream = "text/event-stream";
@@ -180,19 +182,22 @@ static constexpr const char *T_HTTP_CODE_412 = "Precondition Failed";
180182
static constexpr const char *T_HTTP_CODE_413 = "Request Entity Too Large";
181183
static constexpr const char *T_HTTP_CODE_414 = "Request-URI Too Large";
182184
static constexpr const char *T_HTTP_CODE_415 = "Unsupported Media Type";
183-
static constexpr const char *T_HTTP_CODE_416 = "Requested range not satisfiable";
185+
static constexpr const char *T_HTTP_CODE_416 = "Requested Range Not Satisfiable";
184186
static constexpr const char *T_HTTP_CODE_417 = "Expectation Failed";
185187
static constexpr const char *T_HTTP_CODE_429 = "Too Many Requests";
186188
static constexpr const char *T_HTTP_CODE_500 = "Internal Server Error";
187189
static constexpr const char *T_HTTP_CODE_501 = "Not Implemented";
188190
static constexpr const char *T_HTTP_CODE_502 = "Bad Gateway";
189191
static constexpr const char *T_HTTP_CODE_503 = "Service Unavailable";
190192
static constexpr const char *T_HTTP_CODE_504 = "Gateway Time-out";
191-
static constexpr const char *T_HTTP_CODE_505 = "HTTP Version not supported";
193+
static constexpr const char *T_HTTP_CODE_505 = "HTTP Version Not Supported";
192194
static constexpr const char *T_HTTP_CODE_ANY = "Unknown code";
193195

194-
static constexpr const uint8_t T_only_once_headers_len = 11;
195-
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,
196-
T_Transfer_Encoding, T_Content_Location, T_Server, T_WWW_AUTH};
196+
static constexpr const char *T_only_once_headers[] = {
197+
T_Accept_Ranges, T_Content_Length, T_Content_Type, T_Connection, T_CORS_ACAC, T_CORS_ACAH, T_CORS_ACAM, T_CORS_ACAO,
198+
T_CORS_ACMA, T_CORS_O, T_Date, T_DIGEST, T_ETag, T_Last_Modified, T_LOCATION, T_retry_after,
199+
T_Transfer_Encoding, T_Content_Location, T_Server, T_WWW_AUTH
200+
};
201+
static constexpr size_t T_only_once_headers_len = sizeof(T_only_once_headers) / sizeof(T_only_once_headers[0]);
197202

198203
} // namespace asyncsrv

0 commit comments

Comments
 (0)