aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpserver.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2023-11-15 12:19:21 +0100
committerGitHub <[email protected]>2023-11-15 12:19:21 +0100
commit8ff65cd87265b4b5065cbff3290169c417227de7 (patch)
tree69eb9a16dd76ee540c61b3ba3768789d591ba149 /src/zenhttp/httpserver.cpp
parentadd doctest listener so we can output when test/subtests begin (#538) (diff)
downloadzen-8ff65cd87265b4b5065cbff3290169c417227de7.tar.xz
zen-8ff65cd87265b4b5065cbff3290169c417227de7.zip
Make object store endpoint S3 compatible. (#535)
* Make object store endpoint S3 compatible. * Removed XML pretty printing and set object store endpoint disabled by default.
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
-rw-r--r--src/zenhttp/httpserver.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp
index fa75060db..43098b470 100644
--- a/src/zenhttp/httpserver.cpp
+++ b/src/zenhttp/httpserver.cpp
@@ -80,6 +80,9 @@ MapContentTypeToString(HttpContentType ContentType)
case HttpContentType::kIcon:
return "image/x-icon"sv;
+
+ case HttpContentType::kXML:
+ return "application/xml"sv;
}
}
@@ -111,6 +114,7 @@ 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);
+static constinit uint32_t HashXml = HashStringDjb2("application/xml"sv);
std::once_flag InitContentTypeLookup;
@@ -143,6 +147,7 @@ struct HashedTypeEntry
{HashImagePng, HttpContentType::kPNG},
{HashIcon, HttpContentType::kIcon},
{HashImageIcon, HttpContentType::kIcon},
+ {HashXml, HttpContentType::kXML},
// clang-format on
};
@@ -593,6 +598,18 @@ HttpServerRequest::ReadPayloadObject()
{
if (IoBuffer Payload = ReadPayload())
{
+ if (m_ContentType == HttpContentType::kJSON)
+ {
+ std::string Json(reinterpret_cast<const char*>(Payload.GetData()), Payload.GetSize());
+ std::string Err;
+
+ CbFieldIterator It = LoadCompactBinaryFromJson(Json, Err);
+ if (Err.empty())
+ {
+ return It.AsObject();
+ }
+ return CbObject();
+ }
return LoadCompactBinaryObject(std::move(Payload));
}