cookie debug log

This commit is contained in:
acetone
2022-11-22 12:35:09 +03:00
parent c4bb96adb0
commit 84ffdec23d
+4 -8
View File
@@ -26,7 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
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, &currentTrafficVolume) );
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;
}