diff options
| author | Stefan Boberg <[email protected]> | 2022-06-10 14:45:39 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2022-06-10 14:45:39 +0200 |
| commit | a55f7f5cbbdf7f10be59b0fcf1b64156530683bb (patch) | |
| tree | 99156801bd5473cf3653f06da39be70cf61ce3e1 /zenhttp/httpserver.cpp | |
| parent | http: fixed extension parsing logic (diff) | |
| download | zen-a55f7f5cbbdf7f10be59b0fcf1b64156530683bb.tar.xz zen-a55f7f5cbbdf7f10be59b0fcf1b64156530683bb.zip | |
http: added some more content-type aliases/suffixes
Diffstat (limited to 'zenhttp/httpserver.cpp')
| -rw-r--r-- | zenhttp/httpserver.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/zenhttp/httpserver.cpp b/zenhttp/httpserver.cpp index df5a0596a..840b90931 100644 --- a/zenhttp/httpserver.cpp +++ b/zenhttp/httpserver.cpp @@ -76,22 +76,32 @@ MapContentTypeToString(HttpContentType ContentType) } ////////////////////////////////////////////////////////////////////////// +// +// Note that in addition to MIME types we accept abbreviated versions, for +// use in suffix parsing as well as for convenience when using curl static constinit uint32_t HashBinary = HashStringDjb2("application/octet-stream"sv); +static constinit uint32_t HashJson = HashStringDjb2("json"sv); static constinit uint32_t HashApplicationJson = HashStringDjb2("application/json"sv); -static constinit uint32_t HashApplicationYaml = HashStringDjb2("text/yaml"sv); +static constinit uint32_t HashYaml = HashStringDjb2("yaml"sv); +static constinit uint32_t HashTextYaml = HashStringDjb2("text/yaml"sv); static constinit uint32_t HashText = HashStringDjb2("text/plain"sv); -static constinit uint32_t HashCompactBinary = HashStringDjb2("application/x-ue-cb"sv); +static constinit uint32_t HashApplicationCompactBinary = HashStringDjb2("application/x-ue-cb"sv); +static constinit uint32_t HashCompactBinary = HashStringDjb2("ucb"sv); static constinit uint32_t HashCompactBinaryPackage = HashStringDjb2("application/x-ue-cbpkg"sv); +static constinit uint32_t HashCompactBinaryPackageShort = HashStringDjb2("cbpkg"sv); static constinit uint32_t HashCompactBinaryPackageOffer = HashStringDjb2("application/x-ue-offer"sv); static constinit uint32_t HashCompressedBinary = HashStringDjb2("application/x-ue-comp"sv); -static constinit uint32_t HashJson = HashStringDjb2("json"sv); -static constinit uint32_t HashYaml = HashStringDjb2("yaml"sv); -static constinit uint32_t HashHtml = HashStringDjb2("text/html"sv); -static constinit uint32_t HashJavaScript = HashStringDjb2("application/javascript"sv); -static constinit uint32_t HashCss = HashStringDjb2("text/css"sv); -static constinit uint32_t HashPng = HashStringDjb2("image/png"sv); -static constinit uint32_t HashIcon = HashStringDjb2("image/x-icon"sv); +static constinit uint32_t HashHtml = HashStringDjb2("html"sv); +static constinit uint32_t HashTextHtml = HashStringDjb2("text/html"sv); +static constinit uint32_t HashJavaScript = HashStringDjb2("js"sv); +static constinit uint32_t HashApplicationJavaScript = HashStringDjb2("application/javascript"sv); +static constinit uint32_t HashCss = HashStringDjb2("css"sv); +static constinit uint32_t HashTextCss = HashStringDjb2("text/css"sv); +static constinit uint32_t HashPng = HashStringDjb2("png"sv); +static constinit uint32_t HashImagePng = HashStringDjb2("image/png"sv); +static constinit uint32_t HashIcon = HashStringDjb2("ico"sv); +static constinit uint32_t HashImageIcon = HashStringDjb2("image/x-icon"sv); std::once_flag InitContentTypeLookup; @@ -102,20 +112,27 @@ struct HashedTypeEntry } TypeHashTable[] = { // clang-format off {HashBinary, HttpContentType::kBinary}, + {HashApplicationCompactBinary, HttpContentType::kCbObject}, {HashCompactBinary, HttpContentType::kCbObject}, {HashCompactBinaryPackage, HttpContentType::kCbPackage}, + {HashCompactBinaryPackageShort, HttpContentType::kCbPackage}, {HashCompactBinaryPackageOffer, HttpContentType::kCbPackageOffer}, {HashJson, HttpContentType::kJSON}, {HashApplicationJson, HttpContentType::kJSON}, {HashYaml, HttpContentType::kYAML}, - {HashApplicationYaml, HttpContentType::kYAML}, + {HashTextYaml, HttpContentType::kYAML}, {HashText, HttpContentType::kText}, {HashCompressedBinary, HttpContentType::kCompressedBinary}, {HashHtml, HttpContentType::kHTML}, + {HashTextHtml, HttpContentType::kHTML}, {HashJavaScript, HttpContentType::kJavaScript}, + {HashApplicationJavaScript, HttpContentType::kJavaScript}, {HashCss, HttpContentType::kCSS}, + {HashTextCss, HttpContentType::kCSS}, {HashPng, HttpContentType::kPNG}, + {HashImagePng, HttpContentType::kPNG}, {HashIcon, HttpContentType::kIcon}, + {HashImageIcon, HttpContentType::kIcon}, // clang-format on }; |