diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-14 10:12:38 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-28 16:42:12 +0200 |
commit | 5dc1780369927b41b424277330d0e2ec7431252b (patch) | |
tree | 9d17ae0586ced63ab59cada7f52b9af74bc06ee8 | |
parent | c34673e5d918e1882401572f81d8c2d6f54c5459 (diff) |
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>
-rw-r--r-- | src/network/access/qnetworkcookie.cpp | 9 | ||||
-rw-r--r-- | src/network/access/qnetworkcookie_p.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 16c38d89ab..cf1232e37f 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -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) } diff --git a/src/network/access/qnetworkcookie_p.h b/src/network/access/qnetworkcookie_p.h index 13538ad243..e30e611cf5 100644 --- a/src/network/access/qnetworkcookie_p.h +++ b/src/network/access/qnetworkcookie_p.h @@ -66,6 +66,7 @@ public: QString domain; QString path; QString comment; + QByteArray sameSite; QByteArray name; QByteArray value; bool secure; |