Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qhstspolicy.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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
4#include "qhstspolicy.h"
5
6#include <QtCore/qdatetime.h>
7#include <QtCore/qstring.h>
8
10
30/*
31 \enum QHstsPolicy::PolicyFlag
32
33 Specifies attributes that a policy can have.
34
35 \value IncludeSubDomains HSTS policy also applies to subdomains.
36*/
37
39{
40public:
43 bool includeSubDomains = false;
44
46 {
47 return url.host() == other.url.host() && expiry == other.expiry
48 && includeSubDomains == other.includeSubDomains;
49 }
50};
51
69bool QHstsPolicy::isEqual(const QHstsPolicy &other) const
70{
71 return *d == *other.d;
72}
73
81
95QHstsPolicy::QHstsPolicy(const QDateTime &expiry, PolicyFlags flags,
96 const QString &host, QUrl::ParsingMode mode)
98{
99 d->url.setHost(host, mode);
100 d->expiry = expiry;
102}
103
111
118
123{
124 d = other.d;
125 return *this;
126}
127
134{
135 d->url.setHost(host, mode);
136}
137
143QString QHstsPolicy::host(QUrl::ComponentFormattingOptions options) const
144{
145 return d->url.host(options);
146}
147
154{
155 d->expiry = expiry;
156}
157
164{
165 return d->expiry;
166}
167
174{
175 d->includeSubDomains = include;
176}
177
184{
185 return d->includeSubDomains;
186}
187
195{
196 return !d->expiry.isValid() || d->expiry <= QDateTime::currentDateTimeUtc();
197}
198
\inmodule QtCore\reentrant
Definition qdatetime.h:283
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
static QDateTime currentDateTimeUtc()
bool operator==(const QHstsPolicyPrivate &other) const
The QHstsPolicy class specifies that a host supports HTTP Strict Transport Security policy (HSTS).
Definition qhstspolicy.h:19
void setIncludesSubDomains(bool include)
Sets whether subdomains are included for this policy to include.
QHstsPolicy & operator=(const QHstsPolicy &rhs)
Copy-assignment operator, makes a copy of other.
void setExpiry(const QDateTime &expiry)
Sets the expiration date for the policy (in UTC) to expiry.
void setHost(const QString &host, QUrl::ParsingMode mode=QUrl::DecodedMode)
Sets a host, host data is interpreted according to mode parameter.
QDateTime expiry() const
Returns the expiration date for the policy (in UTC).
bool isExpired() const
Return true if this policy has a valid expiration date and this date is greater than QDateTime::curre...
~QHstsPolicy()
Destructor.
QString host(QUrl::ComponentFormattingOptions options=QUrl::FullyDecoded) const
Returns a host for a given policy, formatted according to options.
QHstsPolicy()
Constructs an invalid (expired) policy with empty host name and subdomains not included.
bool includesSubDomains() const
Returns true if this policy also includes subdomains.
\inmodule QtCore
Definition qshareddata.h:19
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition qurl.cpp:2340
ParsingMode
The parsing mode controls the way QUrl parses strings.
Definition qurl.h:96
void setHost(const QString &host, ParsingMode mode=DecodedMode)
Sets the host of the URL to host.
Definition qurl.cpp:2289
Combined button and popup list for selecting options.
GLenum mode
GLbitfield flags
QSharedPointer< T > other(t)
[5]