![]() |
Qt 6.x
The Qt SDK
|
The QHstsPolicy class specifies that a host supports HTTP Strict Transport Security policy (HSTS). More...
#include <qhstspolicy.h>
Public Types | |
enum | PolicyFlag { IncludeSubDomains = 1 } |
\value IncludeSubDomains Indicates whether a policy must include subdomains More... | |
Public Member Functions | |
QHstsPolicy () | |
Constructs an invalid (expired) policy with empty host name and subdomains not included. | |
QHstsPolicy (const QDateTime &expiry, PolicyFlags flags, const QString &host, QUrl::ParsingMode mode=QUrl::DecodedMode) | |
Constructs QHstsPolicy with expiry (in UTC); flags is a value indicating whether this policy must also include subdomains, host data is interpreted according to mode. | |
QHstsPolicy (const QHstsPolicy &rhs) | |
Creates a copy of other object. | |
QHstsPolicy & | operator= (const QHstsPolicy &rhs) |
Copy-assignment operator, makes a copy of other. | |
QHstsPolicy & | operator= (QHstsPolicy &&other) noexcept |
~QHstsPolicy () | |
Destructor. | |
void | swap (QHstsPolicy &other) noexcept |
Swaps this policy with the other policy. | |
void | setHost (const QString &host, QUrl::ParsingMode mode=QUrl::DecodedMode) |
Sets a host, host data is interpreted according to mode parameter. | |
QString | host (QUrl::ComponentFormattingOptions options=QUrl::FullyDecoded) const |
Returns a host for a given policy, formatted according to options. | |
void | setExpiry (const QDateTime &expiry) |
Sets the expiration date for the policy (in UTC) to expiry. | |
QDateTime | expiry () const |
Returns the expiration date for the policy (in UTC). | |
void | setIncludesSubDomains (bool include) |
Sets whether subdomains are included for this policy to include. | |
bool | includesSubDomains () const |
Returns true if this policy also includes subdomains. | |
bool | isExpired () const |
Return true if this policy has a valid expiration date and this date is greater than QDateTime::currentGetDateTimeUtc(). | |
Friends | |
bool | operator== (const QHstsPolicy &lhs, const QHstsPolicy &rhs) |
Returns true if the two policies lhs and rhs have the same host and expiration date while agreeing on whether to include or exclude subdomains. | |
bool | operator!= (const QHstsPolicy &lhs, const QHstsPolicy &rhs) |
Returns true if the two policies lhs and rhs do not have the same host or expiration date, or do not agree on whether to include or exclude subdomains. | |
The QHstsPolicy class specifies that a host supports HTTP Strict Transport Security policy (HSTS).
\inmodule QtNetwork
HSTS policy defines a period of time during which QNetworkAccessManager should only access a host in a secure fashion. HSTS policy is defined by RFC6797.
You can set expiry time and host name for this policy, and control whether it applies to subdomains, either in the constructor or by calling setExpiry(), setHost() and setIncludesSubdomains().
Definition at line 18 of file qhstspolicy.h.
\value IncludeSubDomains Indicates whether a policy must include subdomains
Enumerator | |
---|---|
IncludeSubDomains |
Definition at line 21 of file qhstspolicy.h.
QHstsPolicy::QHstsPolicy | ( | ) |
Constructs an invalid (expired) policy with empty host name and subdomains not included.
Definition at line 78 of file qhstspolicy.cpp.
QHstsPolicy::QHstsPolicy | ( | const QDateTime & | expiry, |
PolicyFlags | flags, | ||
const QString & | host, | ||
QUrl::ParsingMode | mode = QUrl::DecodedMode |
||
) |
Constructs QHstsPolicy with expiry (in UTC); flags is a value indicating whether this policy must also include subdomains, host data is interpreted according to mode.
Definition at line 95 of file qhstspolicy.cpp.
References QHstsPolicyPrivate::expiry, expiry(), host(), QHstsPolicyPrivate::includeSubDomains, IncludeSubDomains, QUrl::setHost(), and QHstsPolicyPrivate::url.
QHstsPolicy::QHstsPolicy | ( | const QHstsPolicy & | rhs | ) |
Creates a copy of other object.
Definition at line 107 of file qhstspolicy.cpp.
QHstsPolicy::~QHstsPolicy | ( | ) |
Destructor.
Definition at line 115 of file qhstspolicy.cpp.
QDateTime QHstsPolicy::expiry | ( | ) | const |
Returns the expiration date for the policy (in UTC).
Definition at line 163 of file qhstspolicy.cpp.
References QHstsPolicyPrivate::expiry.
Referenced by QHstsPolicy(), and setExpiry().
QString QHstsPolicy::host | ( | QUrl::ComponentFormattingOptions | options = QUrl::FullyDecoded | ) | const |
Returns a host for a given policy, formatted according to options.
Definition at line 143 of file qhstspolicy.cpp.
References QUrl::host(), and QHstsPolicyPrivate::url.
Referenced by QHstsPolicy(), and setHost().
bool QHstsPolicy::includesSubDomains | ( | ) | const |
Returns true
if this policy also includes subdomains.
Definition at line 183 of file qhstspolicy.cpp.
References QHstsPolicyPrivate::includeSubDomains.
bool QHstsPolicy::isExpired | ( | ) | const |
Return true
if this policy has a valid expiration date and this date is greater than QDateTime::currentGetDateTimeUtc().
Definition at line 194 of file qhstspolicy.cpp.
References QDateTime::currentDateTimeUtc(), QHstsPolicyPrivate::expiry, and QDateTime::isValid().
QHstsPolicy & QHstsPolicy::operator= | ( | const QHstsPolicy & | rhs | ) |
Copy-assignment operator, makes a copy of other.
Definition at line 122 of file qhstspolicy.cpp.
References other().
|
inlinenoexcept |
Definition at line 32 of file qhstspolicy.h.
References other(), and swap().
Sets the expiration date for the policy (in UTC) to expiry.
Definition at line 153 of file qhstspolicy.cpp.
References QHstsPolicyPrivate::expiry, and expiry().
void QHstsPolicy::setHost | ( | const QString & | host, |
QUrl::ParsingMode | mode = QUrl::DecodedMode |
||
) |
Sets a host, host data is interpreted according to mode parameter.
Definition at line 133 of file qhstspolicy.cpp.
References host(), QUrl::setHost(), and QHstsPolicyPrivate::url.
Referenced by QHstsStore::readPolicies().
void QHstsPolicy::setIncludesSubDomains | ( | bool | include | ) |
Sets whether subdomains are included for this policy to include.
Definition at line 173 of file qhstspolicy.cpp.
References QHstsPolicyPrivate::includeSubDomains.
|
inlinenoexcept |
Swaps this policy with the other policy.
Definition at line 35 of file qhstspolicy.h.
|
friend |
Returns true
if the two policies lhs and rhs do not have the same host or expiration date, or do not agree on whether to include or exclude subdomains.
Definition at line 52 of file qhstspolicy.h.
|
friend |
Returns true
if the two policies lhs and rhs have the same host and expiration date while agreeing on whether to include or exclude subdomains.
Definition at line 50 of file qhstspolicy.h.