From d0630968516f31a9c6ebc9a5643b7cd19f6cb184 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 22 Jan 2024 13:22:21 +0100 Subject: improved errors from jupiter upstream (#636) * get more detailed error messages from jupiter upstream --- src/zenhttp/httpserver.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/zenhttp/httpserver.cpp') diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp index 3270855ad..dcbeac907 100644 --- a/src/zenhttp/httpserver.cpp +++ b/src/zenhttp/httpserver.cpp @@ -94,6 +94,7 @@ MapContentTypeToString(HttpContentType ContentType) 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 HashApplicationProblemJson = HashStringDjb2("application/problem+json"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); @@ -132,6 +133,7 @@ struct HashedTypeEntry {HashCompactBinaryPackageOffer, HttpContentType::kCbPackageOffer}, {HashJson, HttpContentType::kJSON}, {HashApplicationJson, HttpContentType::kJSON}, + {HashApplicationProblemJson, HttpContentType::kJSON}, {HashYaml, HttpContentType::kYAML}, {HashTextYaml, HttpContentType::kYAML}, {HashText, HttpContentType::kText}, @@ -156,7 +158,14 @@ ParseContentTypeImpl(const std::string_view& ContentTypeString) { if (!ContentTypeString.empty()) { - const uint32_t CtHash = HashStringDjb2(ContentTypeString); + size_t ContentEnd = ContentTypeString.find(';'); + if (ContentEnd == std::string_view::npos) + { + ContentEnd = ContentTypeString.length(); + } + std::string_view ContentString(ContentTypeString.substr(0, ContentEnd)); + + const uint32_t CtHash = HashStringDjb2(ContentString); if (auto It = std::lower_bound(std::begin(TypeHashTable), std::end(TypeHashTable), -- cgit v1.2.3