|
@@ -192,6 +192,7 @@ using socket_t = int;
|
|
|
#include <fcntl.h>
|
|
#include <fcntl.h>
|
|
|
#include <fstream>
|
|
#include <fstream>
|
|
|
#include <functional>
|
|
#include <functional>
|
|
|
|
|
+#include <iomanip>
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
#include <list>
|
|
#include <list>
|
|
|
#include <map>
|
|
#include <map>
|
|
@@ -203,7 +204,6 @@ using socket_t = int;
|
|
|
#include <string>
|
|
#include <string>
|
|
|
#include <sys/stat.h>
|
|
#include <sys/stat.h>
|
|
|
#include <thread>
|
|
#include <thread>
|
|
|
-#include <iomanip>
|
|
|
|
|
|
|
|
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
|
#include <openssl/err.h>
|
|
#include <openssl/err.h>
|
|
@@ -1457,26 +1457,19 @@ inline bool is_valid_path(const std::string &path) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-inline std::string encode_query_param(const std::string &value){
|
|
|
|
|
|
|
+inline std::string encode_query_param(const std::string &value) {
|
|
|
std::ostringstream escaped;
|
|
std::ostringstream escaped;
|
|
|
escaped.fill('0');
|
|
escaped.fill('0');
|
|
|
escaped << std::hex;
|
|
escaped << std::hex;
|
|
|
|
|
|
|
|
- for (char const &c: value) {
|
|
|
|
|
- if (std::isalnum(c) ||
|
|
|
|
|
- c == '-' ||
|
|
|
|
|
- c == '_' ||
|
|
|
|
|
- c == '.' ||
|
|
|
|
|
- c == '!' ||
|
|
|
|
|
- c == '~' ||
|
|
|
|
|
- c == '*' ||
|
|
|
|
|
- c == '\'' ||
|
|
|
|
|
- c == '(' ||
|
|
|
|
|
- c == ')') {
|
|
|
|
|
|
|
+ for (char const &c : value) {
|
|
|
|
|
+ if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '!' ||
|
|
|
|
|
+ c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
|
|
|
escaped << c;
|
|
escaped << c;
|
|
|
} else {
|
|
} else {
|
|
|
escaped << std::uppercase;
|
|
escaped << std::uppercase;
|
|
|
- escaped << '%' << std::setw(2) << static_cast<int>(static_cast<unsigned char>(c));
|
|
|
|
|
|
|
+ escaped << '%' << std::setw(2)
|
|
|
|
|
+ << static_cast<int>(static_cast<unsigned char>(c));
|
|
|
escaped << std::nouppercase;
|
|
escaped << std::nouppercase;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2175,9 +2168,9 @@ inline unsigned int str2tag(const std::string &s) {
|
|
|
|
|
|
|
|
namespace udl {
|
|
namespace udl {
|
|
|
|
|
|
|
|
- inline constexpr unsigned int operator"" _(const char *s, size_t l) {
|
|
|
|
|
- return str2tag_core(s, l, 0);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+inline constexpr unsigned int operator"" _(const char *s, size_t l) {
|
|
|
|
|
+ return str2tag_core(s, l, 0);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
} // namespace udl
|
|
} // namespace udl
|
|
|
|
|
|
|
@@ -2192,56 +2185,56 @@ find_content_type(const std::string &path,
|
|
|
using udl::operator""_;
|
|
using udl::operator""_;
|
|
|
|
|
|
|
|
switch (str2tag(ext)) {
|
|
switch (str2tag(ext)) {
|
|
|
- default: return nullptr;
|
|
|
|
|
- case "css"_: return "text/css";
|
|
|
|
|
- case "csv"_: return "text/csv";
|
|
|
|
|
- case "txt"_: return "text/plain";
|
|
|
|
|
- case "vtt"_: return "text/vtt";
|
|
|
|
|
- case "htm"_:
|
|
|
|
|
- case "html"_: return "text/html";
|
|
|
|
|
-
|
|
|
|
|
- case "apng"_: return "image/apng";
|
|
|
|
|
- case "avif"_: return "image/avif";
|
|
|
|
|
- case "bmp"_: return "image/bmp";
|
|
|
|
|
- case "gif"_: return "image/gif";
|
|
|
|
|
- case "png"_: return "image/png";
|
|
|
|
|
- case "svg"_: return "image/svg+xml";
|
|
|
|
|
- case "webp"_: return "image/webp";
|
|
|
|
|
- case "ico"_: return "image/x-icon";
|
|
|
|
|
- case "tif"_: return "image/tiff";
|
|
|
|
|
- case "tiff"_: return "image/tiff";
|
|
|
|
|
- case "jpg"_:
|
|
|
|
|
- case "jpeg"_: return "image/jpeg";
|
|
|
|
|
-
|
|
|
|
|
- case "mp4"_: return "video/mp4";
|
|
|
|
|
- case "mpeg"_: return "video/mpeg";
|
|
|
|
|
- case "webm"_: return "video/webm";
|
|
|
|
|
-
|
|
|
|
|
- case "mp3"_: return "audio/mp3";
|
|
|
|
|
- case "mpga"_: return "audio/mpeg";
|
|
|
|
|
- case "weba"_: return "audio/webm";
|
|
|
|
|
- case "wav"_: return "audio/wave";
|
|
|
|
|
-
|
|
|
|
|
- case "otf"_: return "font/otf";
|
|
|
|
|
- case "ttf"_: return "font/ttf";
|
|
|
|
|
- case "woff"_: return "font/woff";
|
|
|
|
|
- case "woff2"_: return "font/woff2";
|
|
|
|
|
-
|
|
|
|
|
- case "7z"_: return "application/x-7z-compressed";
|
|
|
|
|
- case "atom"_: return "application/atom+xml";
|
|
|
|
|
- case "pdf"_: return "application/pdf";
|
|
|
|
|
- case "js"_:
|
|
|
|
|
- case "mjs"_: return "application/javascript";
|
|
|
|
|
- case "json"_: return "application/json";
|
|
|
|
|
- case "rss"_: return "application/rss+xml";
|
|
|
|
|
- case "tar"_: return "application/x-tar";
|
|
|
|
|
- case "xht"_:
|
|
|
|
|
- case "xhtml"_: return "application/xhtml+xml";
|
|
|
|
|
- case "xslt"_: return "application/xslt+xml";
|
|
|
|
|
- case "xml"_: return "application/xml";
|
|
|
|
|
- case "gz"_: return "application/gzip";
|
|
|
|
|
- case "zip"_: return "application/zip";
|
|
|
|
|
- case "wasm"_: return "application/wasm";
|
|
|
|
|
|
|
+ default: return nullptr;
|
|
|
|
|
+ case "css"_: return "text/css";
|
|
|
|
|
+ case "csv"_: return "text/csv";
|
|
|
|
|
+ case "txt"_: return "text/plain";
|
|
|
|
|
+ case "vtt"_: return "text/vtt";
|
|
|
|
|
+ case "htm"_:
|
|
|
|
|
+ case "html"_: return "text/html";
|
|
|
|
|
+
|
|
|
|
|
+ case "apng"_: return "image/apng";
|
|
|
|
|
+ case "avif"_: return "image/avif";
|
|
|
|
|
+ case "bmp"_: return "image/bmp";
|
|
|
|
|
+ case "gif"_: return "image/gif";
|
|
|
|
|
+ case "png"_: return "image/png";
|
|
|
|
|
+ case "svg"_: return "image/svg+xml";
|
|
|
|
|
+ case "webp"_: return "image/webp";
|
|
|
|
|
+ case "ico"_: return "image/x-icon";
|
|
|
|
|
+ case "tif"_: return "image/tiff";
|
|
|
|
|
+ case "tiff"_: return "image/tiff";
|
|
|
|
|
+ case "jpg"_:
|
|
|
|
|
+ case "jpeg"_: return "image/jpeg";
|
|
|
|
|
+
|
|
|
|
|
+ case "mp4"_: return "video/mp4";
|
|
|
|
|
+ case "mpeg"_: return "video/mpeg";
|
|
|
|
|
+ case "webm"_: return "video/webm";
|
|
|
|
|
+
|
|
|
|
|
+ case "mp3"_: return "audio/mp3";
|
|
|
|
|
+ case "mpga"_: return "audio/mpeg";
|
|
|
|
|
+ case "weba"_: return "audio/webm";
|
|
|
|
|
+ case "wav"_: return "audio/wave";
|
|
|
|
|
+
|
|
|
|
|
+ case "otf"_: return "font/otf";
|
|
|
|
|
+ case "ttf"_: return "font/ttf";
|
|
|
|
|
+ case "woff"_: return "font/woff";
|
|
|
|
|
+ case "woff2"_: return "font/woff2";
|
|
|
|
|
+
|
|
|
|
|
+ case "7z"_: return "application/x-7z-compressed";
|
|
|
|
|
+ case "atom"_: return "application/atom+xml";
|
|
|
|
|
+ case "pdf"_: return "application/pdf";
|
|
|
|
|
+ case "js"_:
|
|
|
|
|
+ case "mjs"_: return "application/javascript";
|
|
|
|
|
+ case "json"_: return "application/json";
|
|
|
|
|
+ case "rss"_: return "application/rss+xml";
|
|
|
|
|
+ case "tar"_: return "application/x-tar";
|
|
|
|
|
+ case "xht"_:
|
|
|
|
|
+ case "xhtml"_: return "application/xhtml+xml";
|
|
|
|
|
+ case "xslt"_: return "application/xslt+xml";
|
|
|
|
|
+ case "xml"_: return "application/xml";
|
|
|
|
|
+ case "gz"_: return "application/gzip";
|
|
|
|
|
+ case "zip"_: return "application/zip";
|
|
|
|
|
+ case "wasm"_: return "application/wasm";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|