mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Merge pull request #20888 from Chocobo1/cookie
Simplify HTTP cookie code
This commit is contained in:
commit
4155d4660f
1 changed files with 4 additions and 5 deletions
|
@ -740,16 +740,15 @@ void WebApplication::sessionStart()
|
||||||
connect(m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::checked, syncController, &SyncController::updateFreeDiskSpace);
|
connect(m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::checked, syncController, &SyncController::updateFreeDiskSpace);
|
||||||
m_currentSession->registerAPIController(u"sync"_s, syncController);
|
m_currentSession->registerAPIController(u"sync"_s, syncController);
|
||||||
|
|
||||||
QNetworkCookie cookie {m_sessionCookieName.toLatin1(), m_currentSession->id().toUtf8()};
|
QNetworkCookie cookie {m_sessionCookieName.toLatin1(), m_currentSession->id().toLatin1()};
|
||||||
cookie.setHttpOnly(true);
|
cookie.setHttpOnly(true);
|
||||||
cookie.setSecure(m_isSecureCookieEnabled && m_isHttpsEnabled);
|
cookie.setSecure(m_isSecureCookieEnabled && m_isHttpsEnabled);
|
||||||
cookie.setPath(u"/"_s);
|
cookie.setPath(u"/"_s);
|
||||||
QByteArray cookieRawForm = cookie.toRawForm();
|
|
||||||
if (m_isCSRFProtectionEnabled)
|
if (m_isCSRFProtectionEnabled)
|
||||||
cookieRawForm.append("; SameSite=Strict");
|
cookie.setSameSitePolicy(QNetworkCookie::SameSite::Strict);
|
||||||
else if (cookie.isSecure())
|
else if (cookie.isSecure())
|
||||||
cookieRawForm.append("; SameSite=None");
|
cookie.setSameSitePolicy(QNetworkCookie::SameSite::None);
|
||||||
setHeader({Http::HEADER_SET_COOKIE, QString::fromLatin1(cookieRawForm)});
|
setHeader({Http::HEADER_SET_COOKIE, QString::fromLatin1(cookie.toRawForm())});
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebApplication::sessionEnd()
|
void WebApplication::sessionEnd()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue