aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpserver.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-12-11 13:09:03 +0100
committerStefan Boberg <[email protected]>2023-12-11 13:09:03 +0100
commit93afeddbc7a5b5df390a29407f5515acd5a70fc1 (patch)
tree6f85ee551aabe20dece64a750c0b2d5d2c5d2d5d /src/zenhttp/httpserver.cpp
parentremoved unnecessary SHA1 references (diff)
parentMake sure that PathFromHandle don't hide true error when throwing exceptions ... (diff)
downloadzen-93afeddbc7a5b5df390a29407f5515acd5a70fc1.tar.xz
zen-93afeddbc7a5b5df390a29407f5515acd5a70fc1.zip
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
-rw-r--r--src/zenhttp/httpserver.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp
index fa75060db..97d6a01fe 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));
}
@@ -756,20 +773,20 @@ CreateHttpServerClass(HttpServerClass Class, const HttpServerConfig& Config)
# if 0
Ref<TransportPlugin> WinsockPlugin{CreateSocketTransportPlugin()};
- WinsockPlugin->Configure("port", "8055");
+ WinsockPlugin->Configure("port", "8558");
Server->AddPlugin(WinsockPlugin);
# endif
# if 0
Ref<TransportPlugin> AsioPlugin{CreateAsioTransportPlugin()};
- AsioPlugin->Configure("port", "8055");
+ AsioPlugin->Configure("port", "8558");
Server->AddPlugin(AsioPlugin);
# endif
# if 1
Ref<DllTransportPlugin> DllPlugin{CreateDllTransportPlugin()};
DllPlugin->LoadDll("winsock");
- DllPlugin->ConfigureDll("winsock", "port", "8055");
+ DllPlugin->ConfigureDll("winsock", "port", "8558");
Server->AddPlugin(DllPlugin);
# endif