7#include "QtNetwork/qnetworkcookie.h"
8#include "QtCore/qurl.h"
9#include "QtCore/qdatetime.h"
10#if QT_CONFIG(topleveldomain)
11#include "private/qtldurl_p.h"
97 return d_func()->allCookies;
112 d->allCookies = cookieList;
168 cookie.normalize(
url);
202 QList<QNetworkCookie>
result;
206 for (
const auto &cookie : std::as_const(
d->allCookies)) {
209 if (!cookie.isSessionCookie() && cookie.expirationDate() <
now)
212 const QString cookieDomain = cookie.domain();
220 domain = domain.
sliced(1);
221#if QT_CONFIG(topleveldomain)
225 if (!domain.
contains(u
'.') && urlHost != domain)
232 auto longerPath = [](
const auto &c1,
const auto &
c2)
233 {
return c1.path().size() >
c2.path().size(); };
257 d->allCookies += cookie;
291 const auto it = std::find_if(
d->allCookies.cbegin(),
d->allCookies.cend(),
292 [&cookie](
const auto &
c) { return c.hasSameIdentifier(cookie); });
293 if (
it !=
d->allCookies.
cend()) {
294 d->allCookies.erase(
it);
315 domain = domain.
sliced(1);
332#include "moc_qnetworkcookiejar.cpp"
\inmodule QtCore\reentrant
static QDateTime currentDateTimeUtc()
The QNetworkCookieJar class implements a simple jar of QNetworkCookie objects.
void setAllCookies(const QList< QNetworkCookie > &cookieList)
Sets the internal list of cookies held by this cookie jar to be cookieList.
virtual ~QNetworkCookieJar()
Destroys this cookie jar object and discards all cookies stored in it.
QList< QNetworkCookie > allCookies() const
Returns all cookies stored in this cookie jar.
virtual QList< QNetworkCookie > cookiesForUrl(const QUrl &url) const
Returns the cookies to be added to when a request is sent to url.
virtual bool insertCookie(const QNetworkCookie &cookie)
QNetworkCookieJar(QObject *parent=nullptr)
Creates a QNetworkCookieJar object and sets the parent object to be parent.
virtual bool updateCookie(const QNetworkCookie &cookie)
virtual bool validateCookie(const QNetworkCookie &cookie, const QUrl &url) const
virtual bool deleteCookie(const QNetworkCookie &cookie)
virtual bool setCookiesFromUrl(const QList< QNetworkCookie > &cookieList, const QUrl &url)
Adds the cookies in the list cookieList to this cookie jar.
The QNetworkCookie class holds one network cookie.
bool isSessionCookie() const
Returns true if this cookie is a session cookie.
QString domain() const
Returns the domain this cookie is associated with.
QDateTime expirationDate() const
Returns the expiration date for this cookie.
const_iterator cend() const noexcept
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
QString scheme() const
Returns the scheme of the URL.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static bool isEncrypted(const my_mach_header *header)
static QT_BEGIN_NAMESPACE bool qIsEffectiveTLD(QStringView domain)
static bool isParentDomain(QStringView domain, QStringView reference)
static bool isParentPath(QStringView path, QStringView reference)
GLsizei const GLchar *const * path
QUrl url("example.com")
[constructor-url-reference]