diff --git a/Includes/Server.h b/Includes/Server.h index 605dd19..0179a90 100644 --- a/Includes/Server.h +++ b/Includes/Server.h @@ -21,6 +21,7 @@ public: void Stop() { m_IsExit = true; } Ref &GetRouter() { return m_Router; } Ref &GetServerConfig() { return m_ServerConfig; } + Ref &GetRequestHandler() { return m_RequestHandler; } Ref &Middleware(); @@ -44,4 +45,4 @@ protected: protected: friend RequestHandler; }; -} \ No newline at end of file +} diff --git a/Source/RequestHandler.cpp b/Source/RequestHandler.cpp index 76c8560..d053e28 100644 --- a/Source/RequestHandler.cpp +++ b/Source/RequestHandler.cpp @@ -68,6 +68,8 @@ void ParseParameters(Request &request, RequestHandler &requestHandler) { request.URI = uri.substr(0, hasURLParameters); } + request.Body = GetPostBody(request.Body); + if (request.Method == HttpMethod::HEAD || request.Method == HttpMethod::GET || request.Method == HttpMethod::OPTIONS) return; @@ -78,11 +80,11 @@ void ParseParameters(Request &request, RequestHandler &requestHandler) { return; auto &key = contentType.GetFirst(); if (key == "application/x-www-form-urlencoded") { - ParseParameterString(request, GetPostBody(request.Body)); + ParseParameterString(request, request.Body); } else { if (requestHandler.HasBodyParser(key)) { auto &func = requestHandler.GetBodyParser(key); - func(request, GetPostBody(request.Body)); + func(request, request.Body); } } }