From 84ffdec23d7c17dd967a57739417219db4864f9b Mon Sep 17 00:00:00 2001 From: acetone Date: Tue, 22 Nov 2022 12:35:09 +0300 Subject: [PATCH] cookie debug log --- src/socketrunnable.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/socketrunnable.cpp b/src/socketrunnable.cpp index 1221d8e..eefb3bd 100644 --- a/src/socketrunnable.cpp +++ b/src/socketrunnable.cpp @@ -26,7 +26,7 @@ along with this program. If not, see . constexpr const int getValueBeforeSpaceLIMIT = 200; constexpr const int getValueBeforeBodyLIMIT = 1000; -constexpr const char* lastTrafficVolumeCookie = "trafficvolume"; +constexpr const char* LAST_TRAFFIC_VOLUME_COOKIE = "trafficvolume"; SocketRunnable::SocketRunnable(qintptr socketDescriptor, QObject *parent) : SocketRunnableBase(socketDescriptor, parent) @@ -37,17 +37,13 @@ void SocketRunnable::get() { if (urlPath() == "/index.html") { - quint64 lastTrafficVolume = 0; const QString cookieString = g::getValue(m_headers, "Cookie", g::GetValueType::HttpHeader); - if (not cookieString.isEmpty()) - { - lastTrafficVolume = g::getValue(m_headers, lastTrafficVolumeCookie).toULongLong(); - } - + quint64 lastTrafficVolume = g::getValue(m_headers, LAST_TRAFFIC_VOLUME_COOKIE).toULongLong(); + qDebug() << "Cookie trafficvolume: raw " << cookieString << "; parsed" << lastTrafficVolume; quint64 currentTrafficVolume = 0; httpDocument().setBody( WebPage::document(lastTrafficVolume, ¤tTrafficVolume) ); httpDocument().setHeader(HttpDocument::CommonHeader::SetCookie, - QString(lastTrafficVolumeCookie)+"="+QString::number(currentTrafficVolume)+"; max-age=31536000;"); + QString(LAST_TRAFFIC_VOLUME_COOKIE)+"="+QString::number(currentTrafficVolume)+"; max-age=31536000;"); return; }