From 7fa622b3dc779ef8ba1bbd2046be79fba39deacd Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Tue, 15 Oct 2024 21:17:13 +0200 Subject: [PATCH 1/3] Revert "Fixed literals for ESP8266" This reverts commit 65906f7419442b7bd4764e9703f7401fd303e92d. --- src/literals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/literals.h b/src/literals.h index fb2af74..778e3db 100644 --- a/src/literals.h +++ b/src/literals.h @@ -4,7 +4,7 @@ namespace asyncsrv { static constexpr const char* empty = ""; -#ifndef ESP8266 +#ifndef ESP8622 static constexpr const char* T__opaque = "\", opaque=\""; static constexpr const char* T_100_CONTINUE = "100-continue"; static constexpr const char* T_13 = "13"; @@ -180,7 +180,7 @@ static constexpr const char* T_HTTP_CODE_504 = "Gateway Time-out"; static constexpr const char* T_HTTP_CODE_505 = "HTTP Version not supported"; static constexpr const char* T_HTTP_CODE_ANY = "Unknown code"; -#else // ESP8266 +#else // ESP8622 static const char T__opaque[] PROGMEM = "\", opaque=\""; static const char T_100_CONTINUE[] PROGMEM = "100-continue"; @@ -356,6 +356,6 @@ static const char T_HTTP_CODE_504[] PROGMEM = "Gateway Time-out"; static const char T_HTTP_CODE_505[] PROGMEM = "HTTP Version not supported"; static const char T_HTTP_CODE_ANY[] PROGMEM = "Unknown code"; -#endif // ESP8266 +#endif // ESP8622 } // namespace asyncsrv {} From a4237ae5e4bb4b600ef3f010f77870829e51788f Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Tue, 15 Oct 2024 21:18:55 +0200 Subject: [PATCH 2/3] Wether 8266 or ESP32, `static constexpr const char*` ws used for literals --- src/literals.h | 521 ++++++++++++++++--------------------------------- 1 file changed, 171 insertions(+), 350 deletions(-) diff --git a/src/literals.h b/src/literals.h index 778e3db..6782390 100644 --- a/src/literals.h +++ b/src/literals.h @@ -2,360 +2,181 @@ namespace asyncsrv { -static constexpr const char* empty = ""; + static constexpr const char* empty = ""; -#ifndef ESP8622 -static constexpr const char* T__opaque = "\", opaque=\""; -static constexpr const char* T_100_CONTINUE = "100-continue"; -static constexpr const char* T_13 = "13"; -static constexpr const char* T_ACCEPT = "accept"; -static constexpr const char* T_Accept_Ranges = "accept-ranges"; -static constexpr const char* T_app_xform_urlencoded = "application/x-www-form-urlencoded"; -static constexpr const char* T_AUTH = "authorization"; -static constexpr const char* T_auth_nonce = "\", qop=\"auth\", nonce=\""; -static constexpr const char* T_BASIC = "basic"; -static constexpr const char* T_BASIC_REALM = "basic realm=\""; -static constexpr const char* T_BEARER = "bearer"; -static constexpr const char* T_BODY = "body"; -static constexpr const char* T_Cache_Control = "cache-control"; -static constexpr const char* T_chunked = "chunked"; -static constexpr const char* T_close = "close"; -static constexpr const char* T_cnonce = "cnonce"; -static constexpr const char* T_Connection = "connection"; -static constexpr const char* T_Content_Disposition = "content-disposition"; -static constexpr const char* T_Content_Encoding = "content-encoding"; -static constexpr const char* T_Content_Length = "content-length"; -static constexpr const char* T_Content_Type = "content-type"; -static constexpr const char* T_Cookie = "cookie"; -static constexpr const char* T_CORS_ACAC = "access-control-allow-credentials"; -static constexpr const char* T_CORS_ACAH = "access-control-allow-headers"; -static constexpr const char* T_CORS_ACAM = "access-control-allow-methods"; -static constexpr const char* T_CORS_ACAO = "access-control-allow-origin"; -static constexpr const char* T_CORS_ACMA = "access-control-max-age"; -static constexpr const char* T_CORS_O = "origin"; -static constexpr const char* T_data_ = "data: "; -static constexpr const char* T_DIGEST = "digest"; -static constexpr const char* T_DIGEST_ = "digest "; -static constexpr const char* T_ETag = "etag"; -static constexpr const char* T_event_ = "event: "; -static constexpr const char* T_EXPECT = "expect"; -static constexpr const char* T_FALSE = "false"; -static constexpr const char* T_filename = "filename"; -static constexpr const char* T_gzip = "gzip"; -static constexpr const char* T_Host = "host"; -static constexpr const char* T_HTTP_1_0 = "HTTP/1.0"; -static constexpr const char* T_HTTP_100_CONT = "HTTP/1.1 100 Continue\r\n\r\n"; -static constexpr const char* T_id__ = "id: "; -static constexpr const char* T_IMS = "if-modified-since"; -static constexpr const char* T_INM = "if-none-match"; -static constexpr const char* T_keep_alive = "keep-alive"; -static constexpr const char* T_Last_Event_ID = "last-event-id"; -static constexpr const char* T_Last_Modified = "last-modified"; -static constexpr const char* T_LOCATION = "location"; -static constexpr const char* T_LOGIN_REQ = "Login Required"; -static constexpr const char* T_MULTIPART_ = "multipart/"; -static constexpr const char* T_name = "name"; -static constexpr const char* T_nc = "nc"; -static constexpr const char* T_no_cache = "no-cache"; -static constexpr const char* T_nonce = "nonce"; -static constexpr const char* T_none = "none"; -static constexpr const char* T_opaque = "opaque"; -static constexpr const char* T_qop = "qop"; -static constexpr const char* T_realm = "realm"; -static constexpr const char* T_realm__ = "realm=\""; -static constexpr const char* T_response = "response"; -static constexpr const char* T_retry_ = "retry: "; -static constexpr const char* T_retry_after = "retry-after"; -static constexpr const char* T_rn = "\r\n"; -static constexpr const char* T_rnrn = "\r\n\r\n"; -static constexpr const char* T_Transfer_Encoding = "transfer-encoding"; -static constexpr const char* T_TRUE = "true"; -static constexpr const char* T_UPGRADE = "upgrade"; -static constexpr const char* T_uri = "uri"; -static constexpr const char* T_username = "username"; -static constexpr const char* T_WS = "websocket"; -static constexpr const char* T_WWW_AUTH = "www-authenticate"; + static constexpr const char* T__opaque = "\", opaque=\""; + static constexpr const char* T_100_CONTINUE = "100-continue"; + static constexpr const char* T_13 = "13"; + static constexpr const char* T_ACCEPT = "accept"; + static constexpr const char* T_Accept_Ranges = "accept-ranges"; + static constexpr const char* T_app_xform_urlencoded = "application/x-www-form-urlencoded"; + static constexpr const char* T_AUTH = "authorization"; + static constexpr const char* T_auth_nonce = "\", qop=\"auth\", nonce=\""; + static constexpr const char* T_BASIC = "basic"; + static constexpr const char* T_BASIC_REALM = "basic realm=\""; + static constexpr const char* T_BEARER = "bearer"; + static constexpr const char* T_BODY = "body"; + static constexpr const char* T_Cache_Control = "cache-control"; + static constexpr const char* T_chunked = "chunked"; + static constexpr const char* T_close = "close"; + static constexpr const char* T_cnonce = "cnonce"; + static constexpr const char* T_Connection = "connection"; + static constexpr const char* T_Content_Disposition = "content-disposition"; + static constexpr const char* T_Content_Encoding = "content-encoding"; + static constexpr const char* T_Content_Length = "content-length"; + static constexpr const char* T_Content_Type = "content-type"; + static constexpr const char* T_Cookie = "cookie"; + static constexpr const char* T_CORS_ACAC = "access-control-allow-credentials"; + static constexpr const char* T_CORS_ACAH = "access-control-allow-headers"; + static constexpr const char* T_CORS_ACAM = "access-control-allow-methods"; + static constexpr const char* T_CORS_ACAO = "access-control-allow-origin"; + static constexpr const char* T_CORS_ACMA = "access-control-max-age"; + static constexpr const char* T_CORS_O = "origin"; + static constexpr const char* T_data_ = "data: "; + static constexpr const char* T_DIGEST = "digest"; + static constexpr const char* T_DIGEST_ = "digest "; + static constexpr const char* T_ETag = "etag"; + static constexpr const char* T_event_ = "event: "; + static constexpr const char* T_EXPECT = "expect"; + static constexpr const char* T_FALSE = "false"; + static constexpr const char* T_filename = "filename"; + static constexpr const char* T_gzip = "gzip"; + static constexpr const char* T_Host = "host"; + static constexpr const char* T_HTTP_1_0 = "HTTP/1.0"; + static constexpr const char* T_HTTP_100_CONT = "HTTP/1.1 100 Continue\r\n\r\n"; + static constexpr const char* T_id__ = "id: "; + static constexpr const char* T_IMS = "if-modified-since"; + static constexpr const char* T_INM = "if-none-match"; + static constexpr const char* T_keep_alive = "keep-alive"; + static constexpr const char* T_Last_Event_ID = "last-event-id"; + static constexpr const char* T_Last_Modified = "last-modified"; + static constexpr const char* T_LOCATION = "location"; + static constexpr const char* T_LOGIN_REQ = "Login Required"; + static constexpr const char* T_MULTIPART_ = "multipart/"; + static constexpr const char* T_name = "name"; + static constexpr const char* T_nc = "nc"; + static constexpr const char* T_no_cache = "no-cache"; + static constexpr const char* T_nonce = "nonce"; + static constexpr const char* T_none = "none"; + static constexpr const char* T_opaque = "opaque"; + static constexpr const char* T_qop = "qop"; + static constexpr const char* T_realm = "realm"; + static constexpr const char* T_realm__ = "realm=\""; + static constexpr const char* T_response = "response"; + static constexpr const char* T_retry_ = "retry: "; + static constexpr const char* T_retry_after = "retry-after"; + static constexpr const char* T_rn = "\r\n"; + static constexpr const char* T_rnrn = "\r\n\r\n"; + static constexpr const char* T_Transfer_Encoding = "transfer-encoding"; + static constexpr const char* T_TRUE = "true"; + static constexpr const char* T_UPGRADE = "upgrade"; + static constexpr const char* T_uri = "uri"; + static constexpr const char* T_username = "username"; + static constexpr const char* T_WS = "websocket"; + static constexpr const char* T_WWW_AUTH = "www-authenticate"; -// HTTP Methods + // HTTP Methods -static constexpr const char* T_ANY = "ANY"; -static constexpr const char* T_GET = "GET"; -static constexpr const char* T_POST = "POST"; -static constexpr const char* T_PUT = "PUT"; -static constexpr const char* T_DELETE = "DELETE"; -static constexpr const char* T_PATCH = "PATCH"; -static constexpr const char* T_HEAD = "HEAD"; -static constexpr const char* T_OPTIONS = "OPTIONS"; -static constexpr const char* T_UNKNOWN = "UNKNOWN"; + static constexpr const char* T_ANY = "ANY"; + static constexpr const char* T_GET = "GET"; + static constexpr const char* T_POST = "POST"; + static constexpr const char* T_PUT = "PUT"; + static constexpr const char* T_DELETE = "DELETE"; + static constexpr const char* T_PATCH = "PATCH"; + static constexpr const char* T_HEAD = "HEAD"; + static constexpr const char* T_OPTIONS = "OPTIONS"; + static constexpr const char* T_UNKNOWN = "UNKNOWN"; -// Req content types -static constexpr const char* T_RCT_NOT_USED = "RCT_NOT_USED"; -static constexpr const char* T_RCT_DEFAULT = "RCT_DEFAULT"; -static constexpr const char* T_RCT_HTTP = "RCT_HTTP"; -static constexpr const char* T_RCT_WS = "RCT_WS"; -static constexpr const char* T_RCT_EVENT = "RCT_EVENT"; -static constexpr const char* T_ERROR = "ERROR"; + // Req content types + static constexpr const char* T_RCT_NOT_USED = "RCT_NOT_USED"; + static constexpr const char* T_RCT_DEFAULT = "RCT_DEFAULT"; + static constexpr const char* T_RCT_HTTP = "RCT_HTTP"; + static constexpr const char* T_RCT_WS = "RCT_WS"; + static constexpr const char* T_RCT_EVENT = "RCT_EVENT"; + static constexpr const char* T_ERROR = "ERROR"; -// extentions & MIME-Types -static constexpr const char* T__css = ".css"; -static constexpr const char* T__eot = ".eot"; -static constexpr const char* T__gif = ".gif"; -static constexpr const char* T__gz = ".gz"; -static constexpr const char* T__htm = ".htm"; -static constexpr const char* T__html = ".html"; -static constexpr const char* T__ico = ".ico"; -static constexpr const char* T__jpg = ".jpg"; -static constexpr const char* T__js = ".js"; -static constexpr const char* T__json = ".json"; -static constexpr const char* T__pdf = ".pdf"; -static constexpr const char* T__png = ".png"; -static constexpr const char* T__svg = ".svg"; -static constexpr const char* T__ttf = ".ttf"; -static constexpr const char* T__woff = ".woff"; -static constexpr const char* T__woff2 = ".woff2"; -static constexpr const char* T__xml = ".xml"; -static constexpr const char* T__zip = ".zip"; -static constexpr const char* T_application_javascript = "application/javascript"; -static constexpr const char* T_application_json = "application/json"; -static constexpr const char* T_application_msgpack = "application/msgpack"; -static constexpr const char* T_application_pdf = "application/pdf"; -static constexpr const char* T_application_x_gzip = "application/x-gzip"; -static constexpr const char* T_application_zip = "application/zip"; -static constexpr const char* T_font_eot = "font/eot"; -static constexpr const char* T_font_ttf = "font/ttf"; -static constexpr const char* T_font_woff = "font/woff"; -static constexpr const char* T_font_woff2 = "font/woff2"; -static constexpr const char* T_image_gif = "image/gif"; -static constexpr const char* T_image_jpeg = "image/jpeg"; -static constexpr const char* T_image_png = "image/png"; -static constexpr const char* T_image_svg_xml = "image/svg+xml"; -static constexpr const char* T_image_x_icon = "image/x-icon"; -static constexpr const char* T_text_css = "text/css"; -static constexpr const char* T_text_event_stream = "text/event-stream"; -static constexpr const char* T_text_html = "text/html"; -static constexpr const char* T_text_plain = "text/plain"; -static constexpr const char* T_text_xml = "text/xml"; + // extentions & MIME-Types + static constexpr const char* T__css = ".css"; + static constexpr const char* T__eot = ".eot"; + static constexpr const char* T__gif = ".gif"; + static constexpr const char* T__gz = ".gz"; + static constexpr const char* T__htm = ".htm"; + static constexpr const char* T__html = ".html"; + static constexpr const char* T__ico = ".ico"; + static constexpr const char* T__jpg = ".jpg"; + static constexpr const char* T__js = ".js"; + static constexpr const char* T__json = ".json"; + static constexpr const char* T__pdf = ".pdf"; + static constexpr const char* T__png = ".png"; + static constexpr const char* T__svg = ".svg"; + static constexpr const char* T__ttf = ".ttf"; + static constexpr const char* T__woff = ".woff"; + static constexpr const char* T__woff2 = ".woff2"; + static constexpr const char* T__xml = ".xml"; + static constexpr const char* T__zip = ".zip"; + static constexpr const char* T_application_javascript = "application/javascript"; + static constexpr const char* T_application_json = "application/json"; + static constexpr const char* T_application_msgpack = "application/msgpack"; + static constexpr const char* T_application_pdf = "application/pdf"; + static constexpr const char* T_application_x_gzip = "application/x-gzip"; + static constexpr const char* T_application_zip = "application/zip"; + static constexpr const char* T_font_eot = "font/eot"; + static constexpr const char* T_font_ttf = "font/ttf"; + static constexpr const char* T_font_woff = "font/woff"; + static constexpr const char* T_font_woff2 = "font/woff2"; + static constexpr const char* T_image_gif = "image/gif"; + static constexpr const char* T_image_jpeg = "image/jpeg"; + static constexpr const char* T_image_png = "image/png"; + static constexpr const char* T_image_svg_xml = "image/svg+xml"; + static constexpr const char* T_image_x_icon = "image/x-icon"; + static constexpr const char* T_text_css = "text/css"; + static constexpr const char* T_text_event_stream = "text/event-stream"; + static constexpr const char* T_text_html = "text/html"; + static constexpr const char* T_text_plain = "text/plain"; + static constexpr const char* T_text_xml = "text/xml"; -// Responce codes -static constexpr const char* T_HTTP_CODE_100 = "Continue"; -static constexpr const char* T_HTTP_CODE_101 = "Switching Protocols"; -static constexpr const char* T_HTTP_CODE_200 = "OK"; -static constexpr const char* T_HTTP_CODE_201 = "Created"; -static constexpr const char* T_HTTP_CODE_202 = "Accepted"; -static constexpr const char* T_HTTP_CODE_203 = "Non-Authoritative Information"; -static constexpr const char* T_HTTP_CODE_204 = "No Content"; -static constexpr const char* T_HTTP_CODE_205 = "Reset Content"; -static constexpr const char* T_HTTP_CODE_206 = "Partial Content"; -static constexpr const char* T_HTTP_CODE_300 = "Multiple Choices"; -static constexpr const char* T_HTTP_CODE_301 = "Moved Permanently"; -static constexpr const char* T_HTTP_CODE_302 = "Found"; -static constexpr const char* T_HTTP_CODE_303 = "See Other"; -static constexpr const char* T_HTTP_CODE_304 = "Not Modified"; -static constexpr const char* T_HTTP_CODE_305 = "Use Proxy"; -static constexpr const char* T_HTTP_CODE_307 = "Temporary Redirect"; -static constexpr const char* T_HTTP_CODE_400 = "Bad Request"; -static constexpr const char* T_HTTP_CODE_401 = "Unauthorized"; -static constexpr const char* T_HTTP_CODE_402 = "Payment Required"; -static constexpr const char* T_HTTP_CODE_403 = "Forbidden"; -static constexpr const char* T_HTTP_CODE_404 = "Not Found"; -static constexpr const char* T_HTTP_CODE_405 = "Method Not Allowed"; -static constexpr const char* T_HTTP_CODE_406 = "Not Acceptable"; -static constexpr const char* T_HTTP_CODE_407 = "Proxy Authentication Required"; -static constexpr const char* T_HTTP_CODE_408 = "Request Time-out"; -static constexpr const char* T_HTTP_CODE_409 = "Conflict"; -static constexpr const char* T_HTTP_CODE_410 = "Gone"; -static constexpr const char* T_HTTP_CODE_411 = "Length Required"; -static constexpr const char* T_HTTP_CODE_412 = "Precondition Failed"; -static constexpr const char* T_HTTP_CODE_413 = "Request Entity Too Large"; -static constexpr const char* T_HTTP_CODE_414 = "Request-URI Too Large"; -static constexpr const char* T_HTTP_CODE_415 = "Unsupported Media Type"; -static constexpr const char* T_HTTP_CODE_416 = "Requested range not satisfiable"; -static constexpr const char* T_HTTP_CODE_417 = "Expectation Failed"; -static constexpr const char* T_HTTP_CODE_429 = "Too Many Requests"; -static constexpr const char* T_HTTP_CODE_500 = "Internal Server Error"; -static constexpr const char* T_HTTP_CODE_501 = "Not Implemented"; -static constexpr const char* T_HTTP_CODE_502 = "Bad Gateway"; -static constexpr const char* T_HTTP_CODE_503 = "Service Unavailable"; -static constexpr const char* T_HTTP_CODE_504 = "Gateway Time-out"; -static constexpr const char* T_HTTP_CODE_505 = "HTTP Version not supported"; -static constexpr const char* T_HTTP_CODE_ANY = "Unknown code"; + // Responce codes + static constexpr const char* T_HTTP_CODE_100 = "Continue"; + static constexpr const char* T_HTTP_CODE_101 = "Switching Protocols"; + static constexpr const char* T_HTTP_CODE_200 = "OK"; + static constexpr const char* T_HTTP_CODE_201 = "Created"; + static constexpr const char* T_HTTP_CODE_202 = "Accepted"; + static constexpr const char* T_HTTP_CODE_203 = "Non-Authoritative Information"; + static constexpr const char* T_HTTP_CODE_204 = "No Content"; + static constexpr const char* T_HTTP_CODE_205 = "Reset Content"; + static constexpr const char* T_HTTP_CODE_206 = "Partial Content"; + static constexpr const char* T_HTTP_CODE_300 = "Multiple Choices"; + static constexpr const char* T_HTTP_CODE_301 = "Moved Permanently"; + static constexpr const char* T_HTTP_CODE_302 = "Found"; + static constexpr const char* T_HTTP_CODE_303 = "See Other"; + static constexpr const char* T_HTTP_CODE_304 = "Not Modified"; + static constexpr const char* T_HTTP_CODE_305 = "Use Proxy"; + static constexpr const char* T_HTTP_CODE_307 = "Temporary Redirect"; + static constexpr const char* T_HTTP_CODE_400 = "Bad Request"; + static constexpr const char* T_HTTP_CODE_401 = "Unauthorized"; + static constexpr const char* T_HTTP_CODE_402 = "Payment Required"; + static constexpr const char* T_HTTP_CODE_403 = "Forbidden"; + static constexpr const char* T_HTTP_CODE_404 = "Not Found"; + static constexpr const char* T_HTTP_CODE_405 = "Method Not Allowed"; + static constexpr const char* T_HTTP_CODE_406 = "Not Acceptable"; + static constexpr const char* T_HTTP_CODE_407 = "Proxy Authentication Required"; + static constexpr const char* T_HTTP_CODE_408 = "Request Time-out"; + static constexpr const char* T_HTTP_CODE_409 = "Conflict"; + static constexpr const char* T_HTTP_CODE_410 = "Gone"; + static constexpr const char* T_HTTP_CODE_411 = "Length Required"; + static constexpr const char* T_HTTP_CODE_412 = "Precondition Failed"; + static constexpr const char* T_HTTP_CODE_413 = "Request Entity Too Large"; + static constexpr const char* T_HTTP_CODE_414 = "Request-URI Too Large"; + static constexpr const char* T_HTTP_CODE_415 = "Unsupported Media Type"; + static constexpr const char* T_HTTP_CODE_416 = "Requested range not satisfiable"; + static constexpr const char* T_HTTP_CODE_417 = "Expectation Failed"; + static constexpr const char* T_HTTP_CODE_429 = "Too Many Requests"; + static constexpr const char* T_HTTP_CODE_500 = "Internal Server Error"; + static constexpr const char* T_HTTP_CODE_501 = "Not Implemented"; + static constexpr const char* T_HTTP_CODE_502 = "Bad Gateway"; + static constexpr const char* T_HTTP_CODE_503 = "Service Unavailable"; + static constexpr const char* T_HTTP_CODE_504 = "Gateway Time-out"; + static constexpr const char* T_HTTP_CODE_505 = "HTTP Version not supported"; + static constexpr const char* T_HTTP_CODE_ANY = "Unknown code"; -#else // ESP8622 - -static const char T__opaque[] PROGMEM = "\", opaque=\""; -static const char T_100_CONTINUE[] PROGMEM = "100-continue"; -static const char T_13[] PROGMEM = "13"; -static const char T_Accept_Ranges[] PROGMEM = "accept-ranges"; -static const char T_ACCEPT[] PROGMEM = "accept"; -static const char T_app_xform_urlencoded[] PROGMEM = "application/x-www-form-urlencoded"; -static const char T_auth_nonce[] PROGMEM = "\", qop=\"auth\", nonce=\""; -static const char T_AUTH[] PROGMEM = "authorization"; -static const char T_BASIC_REALM[] PROGMEM = "basic realm=\""; -static const char T_BASIC[] PROGMEM = "basic"; -static const char T_BEARER[] PROGMEM = "bearer"; -static const char T_BODY[] PROGMEM = "body"; -static const char T_Cache_Control[] PROGMEM = "cache-control"; -static const char T_chunked[] PROGMEM = "chunked"; -static const char T_close[] PROGMEM = "close"; -static const char T_cnonce[] PROGMEM = "cnonce"; -static const char T_Connection[] PROGMEM = "connection"; -static const char T_Content_Disposition[] PROGMEM = "content-disposition"; -static const char T_Content_Encoding[] PROGMEM = "content-encoding"; -static const char T_Content_Length[] PROGMEM = "content-length"; -static const char T_Content_Type[] PROGMEM = "content-type"; -static const char T_Cookie[] PROGMEM = "cookie"; -static const char T_CORS_ACAC[] PROGMEM = "access-control-allow-credentials"; -static const char T_CORS_ACAH[] PROGMEM = "access-control-allow-headers"; -static const char T_CORS_ACAM[] PROGMEM = "access-control-allow-methods"; -static const char T_CORS_ACAO[] PROGMEM = "access-control-allow-origin"; -static const char T_CORS_ACMA[] PROGMEM = "access-control-max-age"; -static const char T_CORS_O[] PROGMEM = "origin"; -static const char T_data_[] PROGMEM = "data: "; -static const char T_DIGEST_[] PROGMEM = "digest "; -static const char T_DIGEST[] PROGMEM = "digest"; -static const char T_ETag[] PROGMEM = "etag"; -static const char T_event_[] PROGMEM = "event: "; -static const char T_EXPECT[] PROGMEM = "expect"; -static const char T_FALSE[] PROGMEM = "false"; -static const char T_filename[] PROGMEM = "filename"; -static const char T_gzip[] PROGMEM = "gzip"; -static const char T_Host[] PROGMEM = "host"; -static const char T_HTTP_1_0[] PROGMEM = "HTTP/1.0"; -static const char T_HTTP_100_CONT[] PROGMEM = "HTTP/1.1 100 Continue\r\n\r\n"; -static const char T_id__[] PROGMEM = "id: "; -static const char T_IMS[] PROGMEM = "if-modified-since"; -static const char T_INM[] PROGMEM = "if-none-match"; -static const char T_keep_alive[] PROGMEM = "keep-alive"; -static const char T_Last_Event_ID[] PROGMEM = "last-event-id"; -static const char T_Last_Modified[] PROGMEM = "last-modified"; -static const char T_LOCATION[] PROGMEM = "location"; -static const char T_LOGIN_REQ[] PROGMEM = "Login Required"; -static const char T_MULTIPART_[] PROGMEM = "multipart/"; -static const char T_name[] PROGMEM = "name"; -static const char T_nc[] PROGMEM = "nc"; -static const char T_no_cache[] PROGMEM = "no-cache"; -static const char T_nonce[] PROGMEM = "nonce"; -static const char T_none[] PROGMEM = "none"; -static const char T_opaque[] PROGMEM = "opaque"; -static const char T_qop[] PROGMEM = "qop"; -static const char T_realm__[] PROGMEM = "realm=\""; -static const char T_realm[] PROGMEM = "realm"; -static const char T_response[] PROGMEM = "response"; -static const char T_retry_[] PROGMEM = "retry: "; -static const char T_retry_after[] PROGMEM = "retry-after"; -static const char T_rn[] PROGMEM = "\r\n"; -static const char T_rnrn[] PROGMEM = "\r\n\r\n"; -static const char T_Transfer_Encoding[] PROGMEM = "transfer-encoding"; -static const char T_TRUE[] PROGMEM = "true"; -static const char T_UPGRADE[] PROGMEM = "upgrade"; -static const char T_uri[] PROGMEM = "uri"; -static const char T_username[] PROGMEM = "username"; -static const char T_WS[] PROGMEM = "websocket"; -static const char T_WWW_AUTH[] PROGMEM = "www-authenticate"; - -// HTTP Methods -static const char T_ANY[] PROGMEM = "ANY"; -static const char T_GET[] PROGMEM = "GET"; -static const char T_POST[] PROGMEM = "POST"; -static const char T_PUT[] PROGMEM = "PUT"; -static const char T_DELETE[] PROGMEM = "DELETE"; -static const char T_PATCH[] PROGMEM = "PATCH"; -static const char T_HEAD[] PROGMEM = "HEAD"; -static const char T_OPTIONS[] PROGMEM = "OPTIONS"; -static const char T_UNKNOWN[] PROGMEM = "UNKNOWN"; - -// Req content types -static const char T_RCT_NOT_USED[] PROGMEM = "RCT_NOT_USED"; -static const char T_RCT_DEFAULT[] PROGMEM = "RCT_DEFAULT"; -static const char T_RCT_HTTP[] PROGMEM = "RCT_HTTP"; -static const char T_RCT_WS[] PROGMEM = "RCT_WS"; -static const char T_RCT_EVENT[] PROGMEM = "RCT_EVENT"; -static const char T_ERROR[] PROGMEM = "ERROR"; - -// extentions & MIME-Types -static const char T__css[] PROGMEM = ".css"; -static const char T__eot[] PROGMEM = ".eot"; -static const char T__gif[] PROGMEM = ".gif"; -static const char T__gz[] PROGMEM = ".gz"; -static const char T__htm[] PROGMEM = ".htm"; -static const char T__html[] PROGMEM = ".html"; -static const char T__ico[] PROGMEM = ".ico"; -static const char T__jpg[] PROGMEM = ".jpg"; -static const char T__js[] PROGMEM = ".js"; -static const char T__json[] PROGMEM = ".json"; -static const char T__pdf[] PROGMEM = ".pdf"; -static const char T__png[] PROGMEM = ".png"; -static const char T__svg[] PROGMEM = ".svg"; -static const char T__ttf[] PROGMEM = ".ttf"; -static const char T__woff[] PROGMEM = ".woff"; -static const char T__woff2[] PROGMEM = ".woff2"; -static const char T__xml[] PROGMEM = ".xml"; -static const char T__zip[] PROGMEM = ".zip"; -static const char T_application_javascript[] PROGMEM = "application/javascript"; -static const char T_application_json[] PROGMEM = "application/json"; -static const char T_application_msgpack[] PROGMEM = "application/msgpack"; -static const char T_application_pdf[] PROGMEM = "application/pdf"; -static const char T_application_x_gzip[] PROGMEM = "application/x-gzip"; -static const char T_application_zip[] PROGMEM = "application/zip"; -static const char T_font_eot[] PROGMEM = "font/eot"; -static const char T_font_ttf[] PROGMEM = "font/ttf"; -static const char T_font_woff[] PROGMEM = "font/woff"; -static const char T_font_woff2[] PROGMEM = "font/woff2"; -static const char T_image_gif[] PROGMEM = "image/gif"; -static const char T_image_jpeg[] PROGMEM = "image/jpeg"; -static const char T_image_png[] PROGMEM = "image/png"; -static const char T_image_svg_xml[] PROGMEM = "image/svg+xml"; -static const char T_image_x_icon[] PROGMEM = "image/x-icon"; -static const char T_text_css[] PROGMEM = "text/css"; -static const char T_text_event_stream[] PROGMEM = "text/event-stream"; -static const char T_text_html[] PROGMEM = "text/html"; -static const char T_text_plain[] PROGMEM = "text/plain"; -static const char T_text_xml[] PROGMEM = "text/xml"; - -// Responce codes -static const char T_HTTP_CODE_100[] PROGMEM = "Continue"; -static const char T_HTTP_CODE_101[] PROGMEM = "Switching Protocols"; -static const char T_HTTP_CODE_200[] PROGMEM = "OK"; -static const char T_HTTP_CODE_201[] PROGMEM = "Created"; -static const char T_HTTP_CODE_202[] PROGMEM = "Accepted"; -static const char T_HTTP_CODE_203[] PROGMEM = "Non-Authoritative Information"; -static const char T_HTTP_CODE_204[] PROGMEM = "No Content"; -static const char T_HTTP_CODE_205[] PROGMEM = "Reset Content"; -static const char T_HTTP_CODE_206[] PROGMEM = "Partial Content"; -static const char T_HTTP_CODE_300[] PROGMEM = "Multiple Choices"; -static const char T_HTTP_CODE_301[] PROGMEM = "Moved Permanently"; -static const char T_HTTP_CODE_302[] PROGMEM = "Found"; -static const char T_HTTP_CODE_303[] PROGMEM = "See Other"; -static const char T_HTTP_CODE_304[] PROGMEM = "Not Modified"; -static const char T_HTTP_CODE_305[] PROGMEM = "Use Proxy"; -static const char T_HTTP_CODE_307[] PROGMEM = "Temporary Redirect"; -static const char T_HTTP_CODE_400[] PROGMEM = "Bad Request"; -static const char T_HTTP_CODE_401[] PROGMEM = "Unauthorized"; -static const char T_HTTP_CODE_402[] PROGMEM = "Payment Required"; -static const char T_HTTP_CODE_403[] PROGMEM = "Forbidden"; -static const char T_HTTP_CODE_404[] PROGMEM = "Not Found"; -static const char T_HTTP_CODE_405[] PROGMEM = "Method Not Allowed"; -static const char T_HTTP_CODE_406[] PROGMEM = "Not Acceptable"; -static const char T_HTTP_CODE_407[] PROGMEM = "Proxy Authentication Required"; -static const char T_HTTP_CODE_408[] PROGMEM = "Request Time-out"; -static const char T_HTTP_CODE_409[] PROGMEM = "Conflict"; -static const char T_HTTP_CODE_410[] PROGMEM = "Gone"; -static const char T_HTTP_CODE_411[] PROGMEM = "Length Required"; -static const char T_HTTP_CODE_412[] PROGMEM = "Precondition Failed"; -static const char T_HTTP_CODE_413[] PROGMEM = "Request Entity Too Large"; -static const char T_HTTP_CODE_414[] PROGMEM = "Request-URI Too Large"; -static const char T_HTTP_CODE_415[] PROGMEM = "Unsupported Media Type"; -static const char T_HTTP_CODE_416[] PROGMEM = "Requested range not satisfiable"; -static const char T_HTTP_CODE_417[] PROGMEM = "Expectation Failed"; -static const char T_HTTP_CODE_429[] PROGMEM = "Too Many Requests"; -static const char T_HTTP_CODE_500[] PROGMEM = "Internal Server Error"; -static const char T_HTTP_CODE_501[] PROGMEM = "Not Implemented"; -static const char T_HTTP_CODE_502[] PROGMEM = "Bad Gateway"; -static const char T_HTTP_CODE_503[] PROGMEM = "Service Unavailable"; -static const char T_HTTP_CODE_504[] PROGMEM = "Gateway Time-out"; -static const char T_HTTP_CODE_505[] PROGMEM = "HTTP Version not supported"; -static const char T_HTTP_CODE_ANY[] PROGMEM = "Unknown code"; - -#endif // ESP8622 - -} // namespace asyncsrv {} +} // namespace asyncsrv {} From 58c4c64dfdeca80f3bbd04d9ffb772a4b9911cae Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Tue, 15 Oct 2024 21:22:52 +0200 Subject: [PATCH 3/3] update example --- examples/SimpleServer/SimpleServer.ino | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/SimpleServer/SimpleServer.ino b/examples/SimpleServer/SimpleServer.ino index 0f42568..2c934ea 100644 --- a/examples/SimpleServer/SimpleServer.ino +++ b/examples/SimpleServer/SimpleServer.ino @@ -87,8 +87,6 @@ const char* htmlContent PROGMEM = R"( )"; -const size_t htmlContentLen = strlen_P(htmlContent); - AsyncWebServer server(80); AsyncEventSource events("/events"); AsyncWebSocket ws("/ws"); @@ -388,7 +386,7 @@ void setup() { // > brew install autocannon // > autocannon -c 10 -w 10 -d 20 http://192.168.4.1 server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { - request->send(200, "text/html", (uint8_t*)htmlContent, htmlContentLen); + request->send(200, "text/html", htmlContent); }); server.on("/file", HTTP_GET, [](AsyncWebServerRequest* request) { @@ -579,7 +577,6 @@ void loop() { } if (now - lastWS >= deltaWS) { ws.printfAll("kp%.4f", (10.0 / 3.0)); - // ws.getClients for (auto& client : ws.getClients()) { client.printf("kp%.4f", (10.0 / 3.0)); }