Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qnetworkcookie.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QNETWORKCOOKIE_H
6#define QNETWORKCOOKIE_H
7
8#include <QtNetwork/qtnetworkglobal.h>
9#include <QtCore/QSharedDataPointer>
10#include <QtCore/QList>
11#include <QtCore/QMetaType>
12#include <QtCore/QObject>
13
15
16
17class QByteArray;
18class QDateTime;
19class QString;
20class QUrl;
21
22class QNetworkCookiePrivate;
23class Q_NETWORK_EXPORT QNetworkCookie
24{
25 Q_GADGET
26public:
27 enum RawForm {
28 NameAndValueOnly,
29 Full
30 };
31 enum class SameSite {
32 Default,
33 None,
34 Lax,
35 Strict
36 };
37 Q_ENUM(SameSite)
38
39 explicit QNetworkCookie(const QByteArray &name = QByteArray(), const QByteArray &value = QByteArray());
40 QNetworkCookie(const QNetworkCookie &other);
41 ~QNetworkCookie();
42 QNetworkCookie &operator=(QNetworkCookie &&other) noexcept { swap(other); return *this; }
43 QNetworkCookie &operator=(const QNetworkCookie &other);
44
45 void swap(QNetworkCookie &other) noexcept { d.swap(other.d); }
46
47 bool operator==(const QNetworkCookie &other) const;
48 inline bool operator!=(const QNetworkCookie &other) const
49 { return !(*this == other); }
50
51 bool isSecure() const;
52 void setSecure(bool enable);
53 bool isHttpOnly() const;
54 void setHttpOnly(bool enable);
55 SameSite sameSitePolicy() const;
56 void setSameSitePolicy(SameSite sameSite);
57
58 bool isSessionCookie() const;
59 QDateTime expirationDate() const;
60 void setExpirationDate(const QDateTime &date);
61
62 QString domain() const;
63 void setDomain(const QString &domain);
64
65 QString path() const;
66 void setPath(const QString &path);
67
68 QByteArray name() const;
69 void setName(const QByteArray &cookieName);
70
71 QByteArray value() const;
72 void setValue(const QByteArray &value);
73
74 QByteArray toRawForm(RawForm form = Full) const;
75
76 bool hasSameIdentifier(const QNetworkCookie &other) const;
77 void normalize(const QUrl &url);
78
79#if QT_NETWORK_REMOVED_SINCE(6, 7)
80 static QList<QNetworkCookie> parseCookies(const QByteArray &cookieString);
81#endif
82 static QList<QNetworkCookie> parseCookies(QByteArrayView cookieString);
83
84private:
85 QSharedDataPointer<QNetworkCookiePrivate> d;
86 friend class QNetworkCookiePrivate;
87};
88
90
91#ifndef QT_NO_DEBUG_STREAM
92class QDebug;
93Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QNetworkCookie &);
94#endif
95
96QT_END_NAMESPACE
97
98QT_DECL_METATYPE_EXTERN(QNetworkCookie, Q_NETWORK_EXPORT)
99
100#endif
The QNetworkCookie class holds one network cookie.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
#define QNetworkAccessBackendFactory_iid