aboutsummaryrefslogtreecommitdiff
path: root/zenhttp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-05 22:25:53 +0200
committerStefan Boberg <[email protected]>2021-10-05 22:25:53 +0200
commit20ac7384f8ca558f1fb933eda846604792240ea0 (patch)
treee5c95b422b847af50b77807af916e389fcaf83aa /zenhttp
parentstats: Mean returns zero when the count is zero (diff)
downloadzen-20ac7384f8ca558f1fb933eda846604792240ea0.tar.xz
zen-20ac7384f8ca558f1fb933eda846604792240ea0.zip
Merged from upstream
Diffstat (limited to 'zenhttp')
-rw-r--r--zenhttp/httpsys.cpp23
-rw-r--r--zenhttp/iothreadpool.cpp6
-rw-r--r--zenhttp/iothreadpool.h8
3 files changed, 26 insertions, 11 deletions
diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp
index fedaf282e..de3069bb8 100644
--- a/zenhttp/httpsys.cpp
+++ b/zenhttp/httpsys.cpp
@@ -1091,29 +1091,34 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService&
if (AbsPathLength >= PrefixLength)
{
// We convert the URI immediately because most of the code involved prefers to deal
- // with utf8. This has some performance impact which I'd prefer to avoid but for now
- // we just have to live with it
+ // with utf8. This is overhead which I'd prefer to avoid but for now we just have
+ // to live with it
WideToUtf8({(char16_t*)HttpRequestPtr->CookedUrl.pAbsPath + PrefixLength, gsl::narrow<size_t>(AbsPathLength - PrefixLength)},
m_UriUtf8);
- std::string_view Uri8{m_UriUtf8};
+ std::string_view UriSuffix8{m_UriUtf8};
- const size_t LastComponentIndex = Uri8.find_last_of('/');
+ const size_t LastComponentIndex = UriSuffix8.find_last_of('/');
if (LastComponentIndex != std::string_view::npos)
{
- Uri8.remove_prefix(LastComponentIndex);
+ UriSuffix8.remove_prefix(LastComponentIndex);
}
- const size_t LastDotIndex = Uri8.find_last_of('.');
+ const size_t LastDotIndex = UriSuffix8.find_last_of('.');
if (LastDotIndex != std::string_view::npos)
{
- Uri8.remove_prefix(LastDotIndex + 1);
- }
+ UriSuffix8.remove_prefix(LastDotIndex + 1);
+
+ AcceptContentType = ParseContentType(UriSuffix8);
- AcceptContentType = ParseContentType(Uri8);
+ if (AcceptContentType != HttpContentType::kUnknownContentType)
+ {
+ m_UriUtf8.RemoveSuffix(uint32_t(m_UriUtf8.Size() - LastComponentIndex - LastDotIndex - 1));
+ }
+ }
}
else
{
diff --git a/zenhttp/iothreadpool.cpp b/zenhttp/iothreadpool.cpp
index 4f1a6642b..6087e69ec 100644
--- a/zenhttp/iothreadpool.cpp
+++ b/zenhttp/iothreadpool.cpp
@@ -4,6 +4,8 @@
#include <zencore/except.h>
+#if ZEN_PLATFORM_WINDOWS
+
namespace zen {
WinIoThreadPool::WinIoThreadPool(int InThreadCount)
@@ -32,6 +34,8 @@ WinIoThreadPool::~WinIoThreadPool()
void
WinIoThreadPool::CreateIocp(HANDLE IoHandle, PTP_WIN32_IO_CALLBACK Callback, void* Context, std::error_code& ErrorCode)
{
+ ZEN_ASSERT(!m_ThreadPoolIo);
+
m_ThreadPoolIo = CreateThreadpoolIo(IoHandle, Callback, Context, &m_CallbackEnvironment);
if (!m_ThreadPoolIo)
@@ -41,3 +45,5 @@ WinIoThreadPool::CreateIocp(HANDLE IoHandle, PTP_WIN32_IO_CALLBACK Callback, voi
}
} // namespace zen
+
+#endif
diff --git a/zenhttp/iothreadpool.h b/zenhttp/iothreadpool.h
index 4418b940b..8333964c3 100644
--- a/zenhttp/iothreadpool.h
+++ b/zenhttp/iothreadpool.h
@@ -2,9 +2,12 @@
#pragma once
-#include <zencore/windows.h>
+#include <zencore/zencore.h>
-#include <system_error>
+#if ZEN_PLATFORM_WINDOWS
+# include <zencore/windows.h>
+
+# include <system_error>
namespace zen {
@@ -31,3 +34,4 @@ private:
};
} // namespace zen
+#endif