9 #include <QHostAddress>
15 : QNetworkCookie(name, value), d(new CookiePrivate)
17 qRegisterMetaType<Cookie>();
18 qRegisterMetaType<QList<Cookie>>();
22 : QNetworkCookie(other), d(other.d)
31 QNetworkCookie::operator=(other);
38 if (QNetworkCookie::operator==(other) && d == other.d) {
42 return QNetworkCookie::operator==(other) && d->sameSite == other.d->sameSite;
52 d->sameSite = sameSite;
60 return QByteArrayLiteral(
"None");
62 return QByteArrayLiteral(
"Lax");
64 return QByteArrayLiteral(
"Strict");
87 result +=
"; HttpOnly";
89 result +=
"; SameSite=";
90 result += sameSiteToRawString(d->sameSite);
92 if (!isSessionCookie()) {
93 result +=
"; expires=";
94 result += QLocale::c().toString(expirationDate().toUTC(),
95 QStringLiteral(
"ddd, dd-MMM-yyyy hh:mm:ss 'GMT")).toLatin1();
97 if (!domain().isEmpty()) {
98 result +=
"; domain=";
99 if (domain().startsWith(u
'.')) {
101 result += QUrl::toAce(domain().mid(1));
103 QHostAddress hostAddr(domain());
104 if (hostAddr.protocol() == QAbstractSocket::IPv6Protocol) {
106 result += domain().toUtf8();
109 result += QUrl::toAce(domain());
113 if (!path().isEmpty()) {
115 result += path().toUtf8();
121 #ifndef QT_NO_DEBUG_STREAM
124 QDebugStateSaver saver(s);
126 s.resetFormat().nospace();
127 s <<
"Cutelyst::Cookie(" << cookie.
toRawForm(Cookie::Full) <<
')';
132 #include "moc_cookie.cpp"
SameSite sameSitePolicy() const
Returns the "SameSite" option if specified in the cookie string, SameSite::Default if not present.
Cookie & operator=(Cookie &&other) noexcept
Move assigns the contents of the Cookie object other to this object.
Cookie(const QByteArray &name=QByteArray(), const QByteArray &value=QByteArray())
Create a new Cookie object, initializing the cookie name to name and its value to value.
void setSameSitePolicy(SameSite sameSite)
Sets the "SameSite" option of this cookie to sameSite.
bool operator==(const Cookie &other) const
Returns true if this cookie is equal to other.
~Cookie()
Destroys this Cookie object.
QByteArray toRawForm(RawForm form=Full) const
Returns the raw form of this Cookie.
The Cutelyst namespace holds all public Cutelyst API.