Pass SameSite through QNetworkCookie

It is an important new details in cookies, as a minimum pass it through,
before we add API for it.

Pick-to: 5.15
Change-Id: I5222a24e0f50f3822a94cce126b5055fed1a8008
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2020-10-14 10:12:38 +02:00
parent c34673e5d9
commit 5dc1780369
2 changed files with 9 additions and 1 deletions

View File

@ -180,7 +180,8 @@ bool QNetworkCookie::operator==(const QNetworkCookie &other) const
d->domain == other.d->domain &&
d->path == other.d->path &&
d->secure == other.d->secure &&
d->comment == other.d->comment;
d->comment == other.d->comment &&
d->sameSite == other.d->sameSite;
}
/*!
@ -459,6 +460,10 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
result += "; secure";
if (isHttpOnly())
result += "; HttpOnly";
if (!d->sameSite.isEmpty()) {
result += "; SameSite=";
result += d->sameSite;
}
if (!isSessionCookie()) {
result += "; expires=";
result += QLocale::c().toString(d->expirationDate.toUTC(),
@ -993,6 +998,8 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
cookie.setSecure(true);
} else if (field.first == "httponly") {
cookie.setHttpOnly(true);
} else if (field.first == "samesite") {
cookie.d->sameSite = field.second;
} else {
// ignore unknown fields in the cookie (RFC6265 section 5.2, rule 6)
}

View File

@ -66,6 +66,7 @@ public:
QString domain;
QString path;
QString comment;
QByteArray sameSite;
QByteArray name;
QByteArray value;
bool secure;