diff options
Diffstat (limited to 'zenhttp')
| -rw-r--r-- | zenhttp/httpasio.cpp | 36 | ||||
| -rw-r--r-- | zenhttp/httpclient.cpp | 4 | ||||
| -rw-r--r-- | zenhttp/httpnull.cpp | 31 | ||||
| -rw-r--r-- | zenhttp/httpserver.cpp | 2 | ||||
| -rw-r--r-- | zenhttp/httpshared.cpp | 2 | ||||
| -rw-r--r-- | zenhttp/httpsys.cpp | 6 | ||||
| -rw-r--r-- | zenhttp/include/zenhttp/httpclient.h | 2 | ||||
| -rw-r--r-- | zenhttp/include/zenhttp/httpserver.h | 2 | ||||
| -rw-r--r-- | zenhttp/include/zenhttp/httpshared.h | 2 | ||||
| -rw-r--r-- | zenhttp/workthreadpool.h | 1 |
10 files changed, 56 insertions, 32 deletions
diff --git a/zenhttp/httpasio.cpp b/zenhttp/httpasio.cpp index ea84e7e87..d94f6af2e 100644 --- a/zenhttp/httpasio.cpp +++ b/zenhttp/httpasio.cpp @@ -9,7 +9,9 @@ #include <memory_resource> ZEN_THIRD_PARTY_INCLUDES_START -#include <conio.h> +#if ZEN_PLATFORM_WINDOWS +# include <conio.h> +#endif #include <http_parser.h> #include <asio.hpp> ZEN_THIRD_PARTY_INCLUDES_END @@ -393,7 +395,7 @@ HttpServerConnection::EnqueueRead() ZEN_TRACE("read: conn#:{} seq#:{} t:{} bytes:{}", m_ConnectionId, m_RequestCounter.load(std::memory_order_relaxed), - GetCurrentThreadId(), + zen::GetCurrentThreadId(), ByteCount); OnDataReceived(Ec, ByteCount); @@ -1017,7 +1019,7 @@ HttpAsioServerRequest::WriteResponse(HttpResponseCode ResponseCode) m_Response.reset(new HttpResponse(HttpContentType::kBinary)); std::array<IoBuffer, 0> Empty; - m_Response->InitializeForPayload((UINT16)ResponseCode, Empty); + m_Response->InitializeForPayload((uint16_t)ResponseCode, Empty); } void @@ -1026,7 +1028,7 @@ HttpAsioServerRequest::WriteResponse(HttpResponseCode ResponseCode, HttpContentT ZEN_ASSERT(!m_Response); m_Response.reset(new HttpResponse(ContentType)); - m_Response->InitializeForPayload((UINT16)ResponseCode, Blobs); + m_Response->InitializeForPayload((uint16_t)ResponseCode, Blobs); } void @@ -1157,6 +1159,13 @@ HttpAsioServer::Run(bool IsInteractive) { const bool TestMode = !IsInteractive; + int WaitTimeout = -1; + if (!TestMode) + { + WaitTimeout = 1000; + } + +#if ZEN_PLATFORM_WINDOWS if (TestMode == false) { zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Press ESC or Q to quit"); @@ -1164,13 +1173,6 @@ HttpAsioServer::Run(bool IsInteractive) do { - int WaitTimeout = -1; - - if (!TestMode) - { - WaitTimeout = 1000; - } - if (!TestMode && _kbhit() != 0) { char c = (char)_getch(); @@ -1183,6 +1185,18 @@ HttpAsioServer::Run(bool IsInteractive) m_ShutdownEvent.Wait(WaitTimeout); } while (!IsApplicationExitRequested()); +#else + if (TestMode == false) + { + zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Ctrl-C to quit"); + } + + do + { + m_ShutdownEvent.Wait(WaitTimeout); + } + while (!IsApplicationExitRequested()); +#endif } void diff --git a/zenhttp/httpclient.cpp b/zenhttp/httpclient.cpp index 6e915e613..e6813d407 100644 --- a/zenhttp/httpclient.cpp +++ b/zenhttp/httpclient.cpp @@ -22,7 +22,7 @@ using namespace std::literals; HttpClient::Response FromCprResponse(cpr::Response& InResponse) { - return {.StatusCode = InResponse.status_code}; + return {.StatusCode = int(InResponse.status_code)}; } ////////////////////////////////////////////////////////////////////////// @@ -130,7 +130,7 @@ HttpClient::TransactPackage(std::string_view Url, CbPackage Package) ResponseBuffer.SetContentType(ContentType); } - return {.StatusCode = FilterResponse.status_code, .ResponsePayload = ResponseBuffer}; + return {.StatusCode = int(FilterResponse.status_code), .ResponsePayload = ResponseBuffer}; } HttpClient::Response diff --git a/zenhttp/httpnull.cpp b/zenhttp/httpnull.cpp index e49051ac5..1a60e211c 100644 --- a/zenhttp/httpnull.cpp +++ b/zenhttp/httpnull.cpp @@ -2,9 +2,12 @@ #include "httpnull.h" -#include <conio.h> #include <zencore/logging.h> +#if ZEN_PLATFORM_WINDOWS +# include <conio.h> +#endif + namespace zen { HttpNullServer::HttpNullServer() @@ -32,6 +35,13 @@ HttpNullServer::Run(bool IsInteractiveSession) { const bool TestMode = !IsInteractiveSession; + int WaitTimeout = -1; + if (!TestMode) + { + WaitTimeout = 1000; + } + +#if ZEN_PLATFORM_WINDOWS if (TestMode == false) { zen::logging::ConsoleLog().info("Zen Server running (null HTTP). Press ESC or Q to quit"); @@ -39,13 +49,6 @@ HttpNullServer::Run(bool IsInteractiveSession) do { - int WaitTimeout = -1; - - if (!TestMode) - { - WaitTimeout = 1000; - } - if (!TestMode && _kbhit() != 0) { char c = (char)_getch(); @@ -58,6 +61,18 @@ HttpNullServer::Run(bool IsInteractiveSession) m_ShutdownEvent.Wait(WaitTimeout); } while (!IsApplicationExitRequested()); +#else + if (TestMode == false) + { + zen::logging::ConsoleLog().info("Zen Server running (null HTTP). Ctrl-C to quit"); + } + + do + { + m_ShutdownEvent.Wait(WaitTimeout); + } + while (!IsApplicationExitRequested()); +#endif } void diff --git a/zenhttp/httpserver.cpp b/zenhttp/httpserver.cpp index f40836c4a..7b729cf0e 100644 --- a/zenhttp/httpserver.cpp +++ b/zenhttp/httpserver.cpp @@ -17,8 +17,6 @@ #include <zencore/thread.h> #include <zenhttp/httpshared.h> -#include <conio.h> -#include <new.h> #include <charconv> #include <mutex> #include <span> diff --git a/zenhttp/httpshared.cpp b/zenhttp/httpshared.cpp index c703409af..ab1463559 100644 --- a/zenhttp/httpshared.cpp +++ b/zenhttp/httpshared.cpp @@ -109,7 +109,7 @@ FormatPackageMessage(const CbPackage& Data) } } - return std::move(ResponseBuffers); + return ResponseBuffers; } CbPackage diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index cdf9e0a39..242954912 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -1221,7 +1221,7 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& const HTTP_REQUEST* HttpRequestPtr = Tx.HttpRequest(); const int PrefixLength = Service.UriPrefixLength(); - const int AbsPathLength = HttpRequestPtr->CookedUrl.AbsPathLength / sizeof(char16_t); + const int AbsPathLength = HttpRequestPtr->CookedUrl.AbsPathLength / sizeof(wchar_t); HttpContentType AcceptContentType = HttpContentType::kUnknownContentType; @@ -1231,7 +1231,7 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& // 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)}, + WideToUtf8({(wchar_t*)HttpRequestPtr->CookedUrl.pAbsPath + PrefixLength, gsl::narrow<size_t>(AbsPathLength - PrefixLength)}, m_UriUtf8); std::string_view UriSuffix8{m_UriUtf8}; @@ -1268,7 +1268,7 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& { --QueryStringLength; // We skip the leading question mark - WideToUtf8({(char16_t*)(HttpRequestPtr->CookedUrl.pQueryString) + 1, QueryStringLength / sizeof(char16_t)}, m_QueryStringUtf8); + WideToUtf8({(wchar_t*)(HttpRequestPtr->CookedUrl.pQueryString) + 1, QueryStringLength / sizeof(wchar_t)}, m_QueryStringUtf8); } else { diff --git a/zenhttp/include/zenhttp/httpclient.h b/zenhttp/include/zenhttp/httpclient.h index 9ece86111..8316a9b9f 100644 --- a/zenhttp/include/zenhttp/httpclient.h +++ b/zenhttp/include/zenhttp/httpclient.h @@ -8,8 +8,6 @@ #include <zencore/uid.h> #include <zenhttp/httpcommon.h> -#include <zencore/windows.h> - ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> ZEN_THIRD_PARTY_INCLUDES_END diff --git a/zenhttp/include/zenhttp/httpserver.h b/zenhttp/include/zenhttp/httpserver.h index 93ba452c7..614cdc2ac 100644 --- a/zenhttp/include/zenhttp/httpserver.h +++ b/zenhttp/include/zenhttp/httpserver.h @@ -46,7 +46,7 @@ public: if (Key.size() == ParamName.size()) { - if (0 == _strnicmp(Key.data(), ParamName.data(), Key.size())) + if (0 == StrCaseCompare(Key.data(), ParamName.data(), Key.size())) { return Kv.second; } diff --git a/zenhttp/include/zenhttp/httpshared.h b/zenhttp/include/zenhttp/httpshared.h index 2e728577d..dc660e45d 100644 --- a/zenhttp/include/zenhttp/httpshared.h +++ b/zenhttp/include/zenhttp/httpshared.h @@ -36,7 +36,7 @@ struct CbPackageHeader static_assert(sizeof(CbPackageHeader) == 16); -static constinit uint32_t kCbPkgMagic = 0xaa77aacc; +enum : uint32_t { kCbPkgMagic = 0xaa77aacc }; struct CbAttachmentEntry { diff --git a/zenhttp/workthreadpool.h b/zenhttp/workthreadpool.h index 6581cc08f..834339d50 100644 --- a/zenhttp/workthreadpool.h +++ b/zenhttp/workthreadpool.h @@ -6,7 +6,6 @@ #include <zencore/blockingqueue.h> #include <zencore/refcount.h> -#include <zencore/windows.h> #include <exception> #include <functional> |