Core/Bnet: Add new loggers to config file template, fixed request/response content logging and fixed setting keep_alive on responses

This commit is contained in:
Shauren
2023-12-18 12:19:10 +01:00
parent acb5fbd48b
commit 15fce17c1a
4 changed files with 15 additions and 10 deletions

View File

@@ -126,9 +126,9 @@ public:
ToStdStringView(context.request.target()), context.response.result_int());
if (sLog->ShouldLog("server.http", LOG_LEVEL_TRACE))
{
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Request: ", this->GetClientInfo(),
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Request: {}", this->GetClientInfo(),
CanLogRequestContent(context) ? SerializeRequest(context.request) : "<REDACTED>");
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Response: ", this->GetClientInfo(),
sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Response: {}", this->GetClientInfo(),
CanLogResponseContent(context) ? std::string_view(reinterpret_cast<char const*>(buffer.GetBasePointer()), buffer.GetActiveSize()) : "<REDACTED>");
}

View File

@@ -73,7 +73,7 @@ RequestHandlerResult DispatcherService::HandleRequest(std::shared_ptr<AbstractSo
SystemTimePoint responseDate = SystemTimePoint::clock::now();
context.response.set(boost::beast::http::field::date, StringFormat("{:%a, %d %b %Y %T GMT}", responseDate - Timezone::GetSystemZoneOffsetAt(responseDate)));
context.response.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
context.response.keep_alive(context.response.keep_alive());
context.response.keep_alive(context.request.keep_alive());
if (!context.handler)
return HandlePathNotFound(std::move(session), context);
@@ -192,12 +192,15 @@ std::shared_ptr<SessionState> SessionService::FindAndRefreshSessionState(std::st
void SessionService::MarkSessionInactive(boost::uuids::uuid const& id)
{
bool wasActive = true;
{
std::unique_lock inactiveSessionsLock{ _inactiveSessionsMutex };
_inactiveSessions.insert(id);
wasActive = _inactiveSessions.insert(id).second;
}
if (wasActive)
{
std::shared_lock lock{ _sessionsMutex };
auto itr = _sessions.find(id);
if (itr != _sessions.end())
{